Message ID | bc432c62f79076f1c1a757d8e41035ed1e7d3100.1531005542.git.rodrigosiqueiramelo@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Sat, Jul 07, 2018 at 08:23:17PM -0300, Rodrigo Siqueira wrote: > This patch fix the following GCC warning: > > intel_reg.c: In function ‘dump_decode’: > warning: ‘snprintf’ output may be truncated before the last format character [-Wformat-truncation=] > snprintf(decode, sizeof(decode), "\n%s", bin); > intel_reg.c:203:3: note: ‘snprintf’ output between 2 and 1025 bytes into a destination of size 1024 > [..] That's an odd error. Line 203: snprintf(decode, sizeof(decode), "\n%s", bin); man snprintf states: The functions snprintf() and vsnprintf() write at most size bytes (including the terminating null byte ('\0')) to str. So this should be truncated correctly. Am I missing something? I'll set up gcc 8.1 tomorrow and poke around. > Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com> > --- > tools/intel_reg.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/intel_reg.c b/tools/intel_reg.c > index ddff2794..15ebb86a 100644 > --- a/tools/intel_reg.c > +++ b/tools/intel_reg.c > @@ -180,7 +180,7 @@ static void to_binary(char *buf, size_t buflen, uint32_t val) > > static void dump_decode(struct config *config, struct reg *reg, uint32_t val) > { > - char decode[1024]; > + char decode[2060]; > char tmp[1024]; > char bin[1024]; > > -- > 2.18.0 >
diff --git a/tools/intel_reg.c b/tools/intel_reg.c index ddff2794..15ebb86a 100644 --- a/tools/intel_reg.c +++ b/tools/intel_reg.c @@ -180,7 +180,7 @@ static void to_binary(char *buf, size_t buflen, uint32_t val) static void dump_decode(struct config *config, struct reg *reg, uint32_t val) { - char decode[1024]; + char decode[2060]; char tmp[1024]; char bin[1024];
This patch fix the following GCC warning: intel_reg.c: In function ‘dump_decode’: warning: ‘snprintf’ output may be truncated before the last format character [-Wformat-truncation=] snprintf(decode, sizeof(decode), "\n%s", bin); intel_reg.c:203:3: note: ‘snprintf’ output between 2 and 1025 bytes into a destination of size 1024 [..] Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com> --- tools/intel_reg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)