From 8f95f74eb2eaa6ac39f02e6d1a43180fe92a414b Mon Sep 17 00:00:00 2001 From: Arthur Heymans Date: Thu, 8 Dec 2022 20:24:44 +0100 Subject: [PATCH] util/cbfstool: Fix building with clang & -Wshadow Clang -Wshadow is more rigorous than GCC and picks a shadowing of the optarg global variable in /usr/include/bits/getopt_core.h . TESTED: builds with both gcc and clang. Change-Id: Ifc362c84511abb6a000671f03498e841d7747074 Signed-off-by: Arthur Heymans Reviewed-on: https://review.coreboot.org/c/coreboot/+/70508 Reviewed-by: Kapil Porwal Reviewed-by: Tarun Tuli Tested-by: build bot (Jenkins) Reviewed-by: Angel Pons Reviewed-by: Subrata Banik --- util/cbfstool/cbfstool.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/util/cbfstool/cbfstool.c b/util/cbfstool/cbfstool.c index 2dcc9d1cb6..c6e451fec2 100644 --- a/util/cbfstool/cbfstool.c +++ b/util/cbfstool/cbfstool.c @@ -340,9 +340,9 @@ static void add_mmap_window(size_t flash_offset, size_t host_offset, } -static int decode_mmap_arg(char *optarg) +static int decode_mmap_arg(char *arg) { - if (optarg == NULL) + if (arg == NULL) return 1; union { @@ -354,17 +354,17 @@ static int decode_mmap_arg(char *optarg) }; } mmap_args; char *suffix = NULL; - char *substring = strtok(optarg, ":"); + char *substring = strtok(arg, ":"); for (size_t i = 0; i < ARRAY_SIZE(mmap_args.array); i++) { if (!substring) { ERROR("Invalid mmap arguments '%s'.\n", - optarg); + arg); return 1; } mmap_args.array[i] = strtol(substring, &suffix, 0); if (suffix && *suffix) { ERROR("Invalid mmap arguments '%s'.\n", - optarg); + arg); return 1; } substring = strtok(NULL, ":"); @@ -372,7 +372,7 @@ static int decode_mmap_arg(char *optarg) if (substring != NULL) { ERROR("Invalid argument, too many substrings '%s'.\n", - optarg); + arg); return 1; }