Skip to content

Commit 6e8c5bb

Browse files
committed
kallsyms: add static relationship between KSYM_NAME_LEN{,_BUFFER}
This adds a static assert to ensure `KSYM_NAME_LEN_BUFFER` gets updated when `KSYM_NAME_LEN` changes. The relationship used is one that keeps the new size (512+1) close to the original buffer size (500). Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Co-developed-by: Boqun Feng <boqun.feng@gmail.com> Signed-off-by: Boqun Feng <boqun.feng@gmail.com> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
1 parent b471927 commit 6e8c5bb

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

scripts/kallsyms.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,18 @@
3232

3333
#define KSYM_NAME_LEN 128
3434

35-
/* A substantially bigger size than the current maximum. */
36-
#define KSYM_NAME_LEN_BUFFER 499
35+
/*
36+
* A substantially bigger size than the current maximum.
37+
*
38+
* It cannot be defined as an expression because it gets stringified
39+
* for the fscanf() format string. Therefore, a _Static_assert() is
40+
* used instead to maintain the relationship with KSYM_NAME_LEN.
41+
*/
42+
#define KSYM_NAME_LEN_BUFFER 512
43+
_Static_assert(
44+
KSYM_NAME_LEN_BUFFER == KSYM_NAME_LEN * 4,
45+
"Please keep KSYM_NAME_LEN_BUFFER in sync with KSYM_NAME_LEN"
46+
);
3747

3848
struct sym_entry {
3949
unsigned long long addr;

0 commit comments

Comments
 (0)