gianfrdp / SDM120C

sdm120c ModBus Mini Smart Meter
GNU General Public License v2.0
72 stars 37 forks source link

specified bound depends on the length of the source argument [-Wstringop-overflow=] #21

Open asarubbo opened 2 years ago

asarubbo commented 2 years ago

By compiling the current master code with -O2 I get:

In file included from /usr/include/string.h:519,
                 from sdm120c.c:39:
In function 'strncpy',
    inlined from 'getPIDcmd' at sdm120c.c:822:9:
/usr/include/bits/string_fortified.h:95:10: warning: '__builtin_strncpy' specified bound depends on the length of the source argument [-Wstringop-overflow=]
   95 |   return __builtin___strncpy_chk (__dest, __src, __len,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   96 |       __glibc_objsize (__dest));
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~
sdm120c.c: In function 'getPIDcmd':
sdm120c.c:820:12: note: length computed here
  820 |     cmdLen=strlen(buffer)+1;
      |            ^~~~~~~~~~~~~~