tools: xenalyze.c fix format-truncation
PATCH 1/1 tools: xenalyze.c fix format-truncation
With gcc optimization enabled by:
tools: detect appropriate debug optimization level b43501451733193b265de30fd79a764363a2a473
-Wformat-truncation throws warnings
gcc version 7.3.0
xenalyze.c: In function 'find_symbol':
xenalyze.c:382:36: error: 'snprintf' output may be truncated before the last format character [-Werror=format-truncation=]
snprintf(name, 128, "(%s +%llx)",
^
xenalyze.c:382:5: note: 'snprintf' output between 6 and 144 bytes into a destination of size 128
snprintf(name, 128, "(%s +%llx)",
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lastname, offset);
~~~~~~~~~~~~~~~~~cc1: all warnings being treated as errors
--- tools/xentrace/xenalyze.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/xentrace/xenalyze.c +2 -2
@@ -358,7 +358,7 @@ char * find_symbol(unsigned long long addr) {int i;char * lastname="ZERO" ;unsigned long long offset=addr; -static char name[128 ]; +static char name[144 ];if (!p) { name[0 ]=0 ;
@@ -379,7 +379,7 @@ char * find_symbol(unsigned long long addr) { p=p->next; } finish: -snprintf (name,128 ,"(%s +%llx)" , +snprintf (name,144 ,"(%s +%llx)" , lastname, offset);return name; }
Signature · 7 lines
2.16.2 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 17 lines · John Thomson
With gcc optimization enabled by:
tools: detect appropriate debug optimization levelb43501451733193b265de30fd79a764363a2a473-Wformat-truncation throws warnings
gcc version 7.3.0
xenalyze.c: In function 'find_symbol':
xenalyze.c:382:36: error: 'snprintf' output may be truncated before the last format character [-Werror=format-truncation=]snprintf(name, 128, "(%s +%llx)", ^ xenalyze.c:382:5: note: 'snprintf' output between 6 and 144 bytes into a destination of size 128 snprintf(name, 128, "(%s +%llx)", ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lastname, offset); ~~~~~~~~~~~~~~~~~
Quoted 3 lines
cc1: all warnings being treated as errors
Signed-off-by John Thomson <[email protected]>
It probably really wants to include SYMBOL_NAME_SIZE somewhere, but that's a minor clean-up for another day. :-)
Thanks!
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel