[igt-dev] [PATCH i-g-t 4/7] Fix truncate string in the snprintf

Rodrigo Siqueira rodrigosiqueiramelo at gmail.com
Sat Jul 7 23:23:17 UTC 2018


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 at 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



More information about the igt-dev mailing list