Commit: aarch64.em: Fix Clang compilation warning
Nick Clifton
nickc@redhat.com
Thu Dec 5 09:58:33 GMT 2024
Hi Guys,
I am checking in the patch below as an obvious fix for the compile
time warning messages generated by Clang when compiling the binutils
for AArch64 targets:
eaarch64cloudabi.c:378:50: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
378 | aarch64_parse_feature_report_option (const char *optarg,
/work/sources/binutils/upstream/current/ld/../include/getopt.h:35:14: note: previous declaration is here
35 | extern char *optarg;
eaarch64cloudabi.c:400:46: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
400 | aarch64_parse_bti_report_option (const char *optarg)
/work/sources/binutils/upstream/current/ld/../include/getopt.h:35:14: note: previous declaration is here
35 | extern char *optarg;
eaarch64cloudabi.c:413:46: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
413 | aarch64_parse_gcs_report_option (const char *optarg)
/work/sources/binutils/upstream/current/ld/../include/getopt.h:35:14: note: previous declaration is here
35 | extern char *optarg;
eaarch64cloudabi.c:426:39: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
426 | aarch64_parse_gcs_option (const char *optarg)
/work/sources/binutils/upstream/current/ld/../include/getopt.h:35:14: note: previous declaration is here
35 | extern char *optarg;
Cheers
Nick
diff --git a/ld/emultempl/aarch64elf.em b/ld/emultempl/aarch64elf.em
index 6dcb296c671..b4c9016a3e5 100644
--- a/ld/emultempl/aarch64elf.em
+++ b/ld/emultempl/aarch64elf.em
@@ -354,34 +354,34 @@ aarch64_elf_create_output_section_statements (void)
}
static bool
-aarch64_parse_feature_report_option (const char *optarg,
+aarch64_parse_feature_report_option (const char *_optarg,
const char *report_opt,
const size_t report_opt_len,
aarch64_feature_marking_report *level)
{
- if (strncmp (optarg, report_opt, report_opt_len) != 0)
+ if (strncmp (_optarg, report_opt, report_opt_len) != 0)
return false;
- if (strlen (optarg) == report_opt_len
- || strcmp (optarg + report_opt_len, "=warning") == 0)
+ if (strlen (_optarg) == report_opt_len
+ || strcmp (_optarg + report_opt_len, "=warning") == 0)
*level = MARKING_WARN;
- else if (strcmp (optarg + report_opt_len, "=none") == 0)
+ else if (strcmp (_optarg + report_opt_len, "=none") == 0)
*level = MARKING_NONE;
- else if (strcmp (optarg + report_opt_len, "=error") == 0)
+ else if (strcmp (_optarg + report_opt_len, "=error") == 0)
*level = MARKING_ERROR;
else
- einfo (_("%X%P: error: unrecognized value '-z %s'\n"), optarg);
+ einfo (_("%X%P: error: unrecognized value '-z %s'\n"), _optarg);
return true;
}
static bool
-aarch64_parse_bti_report_option (const char *optarg)
+aarch64_parse_bti_report_option (const char *_optarg)
{
#define BTI_REPORT "bti-report"
#define BTI_REPORT_LEN COMPILE_TIME_STRLEN (BTI_REPORT)
- return aarch64_parse_feature_report_option (optarg, BTI_REPORT,
+ return aarch64_parse_feature_report_option (_optarg, BTI_REPORT,
BTI_REPORT_LEN, &sw_protections.bti_report);
#undef BTI_REPORT
@@ -389,12 +389,12 @@ aarch64_parse_bti_report_option (const char *optarg)
}
static bool
-aarch64_parse_gcs_report_option (const char *optarg)
+aarch64_parse_gcs_report_option (const char *_optarg)
{
#define GCS_REPORT "gcs-report"
#define GCS_REPORT_LEN COMPILE_TIME_STRLEN (GCS_REPORT)
- return aarch64_parse_feature_report_option (optarg, GCS_REPORT,
+ return aarch64_parse_feature_report_option (_optarg, GCS_REPORT,
GCS_REPORT_LEN, &sw_protections.gcs_report);
#undef GCS_REPORT
@@ -402,22 +402,22 @@ aarch64_parse_gcs_report_option (const char *optarg)
}
static bool
-aarch64_parse_gcs_option (const char *optarg)
+aarch64_parse_gcs_option (const char *_optarg)
{
#define GCS "gcs"
#define GCS_LEN COMPILE_TIME_STRLEN (GCS)
- if (strncmp (optarg, GCS, GCS_LEN) != 0)
+ if (strncmp (_optarg, GCS, GCS_LEN) != 0)
return false;
- if (strcmp (optarg + GCS_LEN, "=always") == 0)
+ if (strcmp (_optarg + GCS_LEN, "=always") == 0)
sw_protections.gcs_type = GCS_ALWAYS;
- else if (strcmp (optarg + GCS_LEN, "=never") == 0)
+ else if (strcmp (_optarg + GCS_LEN, "=never") == 0)
sw_protections.gcs_type = GCS_NEVER;
- else if (strcmp (optarg + GCS_LEN, "=implicit") == 0)
+ else if (strcmp (_optarg + GCS_LEN, "=implicit") == 0)
sw_protections.gcs_type = GCS_IMPLICIT;
else
- einfo (_("%X%P: error: unrecognized value '-z %s'\n"), optarg);
+ einfo (_("%X%P: error: unrecognized value '-z %s'\n"), _optarg);
return true;
More information about the Binutils
mailing list