kallsyms: use `ARRAY_SIZE` instead of hardcoded size
authorBoqun Feng <boqun.feng@gmail.com>
Wed, 27 Jul 2022 15:58:20 +0000 (17:58 +0200)
committerMiguel Ojeda <ojeda@kernel.org>
Wed, 28 Sep 2022 06:54:17 +0000 (08:54 +0200)
This removes one place where the `500` constant is hardcoded.

Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Geert Stappers <stappers@stappers.nl>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Co-developed-by: Miguel Ojeda <ojeda@kernel.org>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
scripts/kallsyms.c

index f18e6df..8551513 100644 (file)
@@ -206,7 +206,7 @@ static struct sym_entry *read_symbol(FILE *in)
 
        rc = fscanf(in, "%llx %c %499s\n", &addr, &type, name);
        if (rc != 3) {
-               if (rc != EOF && fgets(name, 500, in) == NULL)
+               if (rc != EOF && fgets(name, ARRAY_SIZE(name), in) == NULL)
                        fprintf(stderr, "Read error or end of file.\n");
                return NULL;
        }