rockchip-linux / rkdeveloptool

GNU General Public License v2.0
146 stars 85 forks source link

make error? #80

Open develperbayman opened 1 year ago

develperbayman commented 1 year ago

make[1]: Entering directory '/home/developerbayman/rkdeveloptool' g++ -DHAVE_CONFIG_H -I. -I./cfg -Wall -Werror -Wextra -Wreturn-type -fno-strict-aliasing -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE -I/usr/include/libusb-1.0 -g -O2 -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o main.cpp main.cpp: In function ‘bool _Z9mergeBootv.part.0()’: main.cpp:1493:43: error: ‘%s’ directive output may be truncated writing up to 557 bytes into a region of size 5 [-Werror=format-truncation=] 1493 | snprintf(buffer, sizeof(buffer), "%s", chip); | ^~ ...... 1534 | chipType = convertChipType(chip + 2); | ~~~~~ In file included from /usr/include/stdio.h:894, from DefineHeader.h:3, from main.cpp:11: /usr/include/x86_64-linux-gnu/bits/stdio2.h:71:35: note: ‘builtin_snprintf’ output between 1 and 558 bytes into a destination of size 5 71 | return _builtinsnprintf_chk (s, n, USE_FORTIFY_LEVEL - 1, | ~~~~~^~~~~~~~~~~ 72 | glibc_objsize (s), fmt, | ~~~~~~~~~ 73 | __va_arg_pack ()); | ~~~~~ cc1plus: all warnings being treated as errors make[1]: [Makefile:491: main.o] Error 1 make[1]: Leaving directory '/home/developerbayman/rkdeveloptool' make: [Makefile:511: install-recursive] Error 1

VilleWitt commented 1 year ago

Temporary, one could add ignore the format-truncation error from GCC:

snprintf(buffer, sizeof(buffer), "%s", chip);

into

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-truncation"
    snprintf(buffer, sizeof(buffer), "%s", chip);
#pragma GCC diagnostic pop

In main.cpp:covertChipType(...)

mainmachine commented 1 year ago

Looks like this might be an actual fix:

https://github.com/rockchip-linux/rkdeveloptool/issues/70

KSNWH commented 1 year ago

Hi, as buffer is 5 characters you can just change the line 1493 to: snprintf(buffer, sizeof(buffer), ".4%s", chip); (according to https://cplusplus.com/reference/cstdio/printf/)