Skip to contentSkip to conversation

xenalyze: correct symbol name length fscanf() specifier

PATCH In review Jan Beulich 3 participants 3 messages Jul 28, 2025 – Jul 31, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xenalyze: correct symbol name length fscanf() specifier

SYMBOL_NAME_SIZE is 124, not 128. Use the symbolic name there as well, to avoid any disconnect.

While there correct indentation on the following line as well.

Coverity ID: 1659391

---
There's no useful Fixes: tag; the code was imported from HG this way about 10 years ago.

tools/xentrace/xenalyze.c +2 -3
@@ -321,11 +321,10 @@ void parse_symbol_file(char *fn) {
             (*p)->next=NULL;
         }
 
-        /* FIXME -- use SYMBOL_NAME_SIZE */
         /* FIXME -- use regexp.  This won't work for symbols with spaces (yes they exist) */
         (*p)->symbols[(*p)->count].addr = 0xDEADBEEF;
-        if ( fscanf(symbol_file, "%llx %128s",
-               &(*p)->symbols[(*p)->count].addr,
+        if ( fscanf(symbol_file, "%llx %" STR(SYMBOL_NAME_SIZE) "s",
+                    &(*p)->symbols[(*p)->count].addr,
                     (*p)->symbols[(*p)->count].name) == 0 )
             break;
 
Reviewed-by on v1 1/1
#1 lore raw
Quoted 14 lines · Jan Beulich

SYMBOL_NAME_SIZE is 124, not 128. Use the symbolic name there as well, to avoid any disconnect.

While there correct indentation on the following line as well.

Coverity ID: 1659391

---
There's no useful Fixes: tag; the code was imported from HG this way about 10 years ago.

tools/xentrace/xenalyze.c void parse_symbol_file(char *fn) { · line 326

Quoted 9 lines
tools/xentrace/xenalyze.c +1 -3
@@ -321,11 +321,10 @@ void parse_symbol_file(char *fn) {
             (*p)->next=NULL;
         }
 
-        /* FIXME -- use SYMBOL_NAME_SIZE */
         /* FIXME -- use regexp.  This won't work for symbols with spaces (yes they exist) */
         (*p)->symbols[(*p)->count].addr = 0xDEADBEEF;
-        if ( fscanf(symbol_file, "%llx %128s",
-               &(*p)->symbols[(*p)->count].addr,
+        if ( fscanf(symbol_file, "%llx %" STR(SYMBOL_NAME_SIZE) "s",

nit: A comment at the #define stating it's used this way would prevent future "oops" situations when/if someone tries to do (e.g) "#define SYMBOL_NAME_SIZE (1 << 4)"

Though arguably that would cause a compile-time error anyway (except perhaps an octal literal?), so meh. With or without the adjustment:

Quoted 4 lines
tools/xentrace/xenalyze.c +1 -0
+                    &(*p)->symbols[(*p)->count].addr,
                     (*p)->symbols[(*p)->count].name) == 0 )
             break;
 
#2 lore raw
Quoted 29 lines · Alejandro Vallejo
Quoted 14 lines · Jan Beulich

SYMBOL_NAME_SIZE is 124, not 128. Use the symbolic name there as well, to avoid any disconnect.

While there correct indentation on the following line as well.

Coverity ID: 1659391

---
There's no useful Fixes: tag; the code was imported from HG this way about 10 years ago.

tools/xentrace/xenalyze.c void parse_symbol_file(char *fn) { · line 326

Quoted 9 lines
tools/xentrace/xenalyze.c +1 -3
@@ -321,11 +321,10 @@ void parse_symbol_file(char *fn) {
             (*p)->next=NULL;
         }
 
-        /* FIXME -- use SYMBOL_NAME_SIZE */
         /* FIXME -- use regexp.  This won't work for symbols with spaces (yes they exist) */
         (*p)->symbols[(*p)->count].addr = 0xDEADBEEF;
-        if ( fscanf(symbol_file, "%llx %128s",
-               &(*p)->symbols[(*p)->count].addr,
+        if ( fscanf(symbol_file, "%llx %" STR(SYMBOL_NAME_SIZE) "s",

nit: A comment at the #define stating it's used this way would prevent future "oops" situations when/if someone tries to do (e.g) "#define SYMBOL_NAME_SIZE (1 << 4)"

Quoted 4 lines

Though arguably that would cause a compile-time error anyway (except perhaps an octal literal?), so meh. With or without the adjustment:

Thanks,

Signature · 1 line
Anthony PERARD