diff options
author | Damien Le Moal <damien.lemoal@wdc.com> | 2020-09-09 16:18:03 +0900 |
---|---|---|
committer | Waldemar Brodkorb <wbx@openadk.org> | 2020-09-13 15:32:46 +0200 |
commit | b1ed80b54e19345f8846d250098128aea49c1b67 (patch) | |
tree | f05afa0554feaba6a29a838fe1b351cb31aeb0f0 /utils | |
parent | 6f9e85a6219ba4516261159a25c1d42eacb66662 (diff) |
utils/getconf: Fix compilation error
In the main() function, all cases of the "switch (specs[i].num)"
switch-case are all conditionally defined. Depending on the target
environementi, none of them may endup being defined, resulting in the
code block before the no-op default case to generate a
"warning: statement will never be executed" compilation error.
Avoid this by conditionally defining this code block with the macro
DO_GETCONF_NAME which is itself defined if any of the switc cases is
defined too.
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Diffstat (limited to 'utils')
-rw-r--r-- | utils/getconf.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/utils/getconf.c b/utils/getconf.c index 3dd3d75d9..b8d00f90f 100644 --- a/utils/getconf.c +++ b/utils/getconf.c @@ -1154,7 +1154,6 @@ environment SPEC.\n\n"); const char *spec = NULL; char buf[sizeof "POSIX_V6_LPBIG_OFFBIG"]; - char *argv0 = argv[0]; if (argc > 1 && strncmp (argv[1], "-v", 2) == 0) { if (argv[1][2] == '\0') @@ -1199,42 +1198,56 @@ environment SPEC.\n\n"); switch (specs[i].num) { +#undef DO_GETCONF_NAME #if !defined(_XBS5_ILP32_OFF32) && defined(_SC_XBS5_ILP32_OFF32) +#define DO_GETCONF_NAME case _SC_XBS5_ILP32_OFF32: #endif #if !defined(_XBS5_ILP32_OFFBIG) && defined(_SC_XBS5_ILP32_OFFBIG) +#define DO_GETCONF_NAME case _SC_XBS5_ILP32_OFFBIG: #endif #if !defined(_XBS5_LP64_OFF64) && defined(_SC_XBS5_LP64_OFF64) +#define DO_GETCONF_NAME case _SC_XBS5_LP64_OFF64: #endif #if !defined(_XBS5_LPBIG_OFFBIG) && defined(_SC_XBS5_LPBIG_OFFBIG) +#define DO_GETCONF_NAME case _SC_XBS5_LPBIG_OFFBIG: #endif #if !defined(_POSIX_V6_ILP32_OFF32) && defined(_SC_V6_ILP32_OFF32) +#define DO_GETCONF_NAME case _SC_V6_ILP32_OFF32: #endif #if !defined(_POSIX_V6_ILP32_OFFBIG) && defined(_SC_V6_ILP32_OFFBIG) +#define DO_GETCONF_NAME case _SC_V6_ILP32_OFFBIG: #endif #if !defined(_POSIX_V6_LP64_OFF64) && defined(_SC_V6_LP64_OFF64) +#define DO_GETCONF_NAME case _SC_V6_LP64_OFF64: #endif #if !defined(_POSIX_V6_LPBIG_OFFBIG) && defined(_SC_V6_LPBIG_OFFBIG) +#define DO_GETCONF_NAME case _SC_V6_LPBIG_OFFBIG: #endif #if !defined(_POSIX_V7_ILP32_OFF32) && defined(_SC_V7_ILP32_OFF32) +#define DO_GETCONF_NAME case _SC_V7_ILP32_OFF32: #endif #if !defined(_POSIX_V7_ILP32_OFFBIG) && defined(_SC_V7_ILP32_OFFBIG) +#define DO_GETCONF_NAME case _SC_V7_ILP32_OFFBIG: #endif #if !defined(_POSIX_V7_LP64_OFF64) && defined(_SC_V7_LP64_OFF64) +#define DO_GETCONF_NAME case _SC_V7_LP64_OFF64: #endif #if !defined(_POSIX_V7_LPBIG_OFFBIG) && defined(_SC_V7_LPBIG_OFFBIG) +#define DO_GETCONF_NAME case _SC_V7_LPBIG_OFFBIG: #endif +#ifdef DO_GETCONF_NAME { const char *args[argc + 3]; size_t spec_len = strlen (spec); @@ -1242,14 +1255,15 @@ environment SPEC.\n\n"); memcpy (mempcpy (mempcpy (getconf_name, getconf_dir, getconf_dirlen), "/", 1), spec, spec_len + 1); - args[0] = argv0; + args[0] = argv[0]; args[1] = "-v"; args[2] = spec; memcpy (&args[3], &argv[1], argc * sizeof (argv[1])); execv (getconf_name, (char * const *) args); error (4, errno, _("Couldn't execute %s"), getconf_name); } - default: +#endif + default: break; } } |