diff options
author | Jim Meyering <jim@meyering.net> | 2002-07-18 18:35:42 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2002-07-18 18:35:42 +0000 |
commit | a19f9253c46f191ce41858f8c6a37bbb02f8ba87 (patch) | |
tree | 8caabf9637a872f2de5382d522c34778776fca1b | |
parent | 510f7bfe8790b75cc84742626e4a171e3727bf1f (diff) | |
download | coreutils-a19f9253c46f191ce41858f8c6a37bbb02f8ba87.tar.xz |
(main): Test sysctl(...) >= 0, not == 0, since
on NetBSD the return value may well be positive.
Use one-line aggregate initializations.
Use tightly scoped static buffers to avoid warnings about
unused variables on some systems.
-rw-r--r-- | src/uname.c | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/src/uname.c b/src/uname.c index d9acf74c4..3b9403724 100644 --- a/src/uname.c +++ b/src/uname.c @@ -240,19 +240,20 @@ main (int argc, char **argv) if (toprint & PRINT_PROCESSOR) { char const *element = unknown; - char processor[257]; -#if defined (HAVE_SYSINFO) && defined (SI_ARCHITECTURE) - if (0 <= sysinfo (SI_ARCHITECTURE, processor, sizeof processor)) - element = processor; +#if HAVE_SYSINFO && defined SI_ARCHITECTURE + { + static char processor[257]; + if (0 <= sysinfo (SI_ARCHITECTURE, processor, sizeof processor)) + element = processor; + } #endif #ifdef UNAME_PROCESSOR if (element == unknown) { + static char processor[257]; size_t s = sizeof processor; - int mib[2]; - mib[0] = CTL_HW; - mib[1] = UNAME_PROCESSOR; - if (sysctl (mib, 2, processor, &s, 0, 0) == 0) + static int mib[] = { CTL_HW, UNAME_PROCESSOR }; + if (sysctl (mib, 2, processor, &s, 0, 0) >= 0) element = processor; } #endif @@ -262,20 +263,21 @@ main (int argc, char **argv) if (toprint & PRINT_HARDWARE_PLATFORM) { char const *element = unknown; - char hardware_platform[257]; -#if defined (HAVE_SYSINFO) && defined (SI_PLATFORM) - if (0 <= sysinfo (SI_PLATFORM, - hardware_platform, sizeof hardware_platform)) - element = hardware_platform; +#if HAVE_SYSINFO && defined SI_PLATFORM + { + static char hardware_platform[257]; + if (0 <= sysinfo (SI_PLATFORM, + hardware_platform, sizeof hardware_platform)) + element = hardware_platform; + } #endif #ifdef UNAME_HARDWARE_PLATFORM if (element == unknown) { + static char hardware_platform[257]; size_t s = sizeof hardware_platform; - int mib[2]; - mib[0] = CTL_HW; - mib[1] = UNAME_HARDWARE_PLATFORM; - if (sysctl (mib, 2, hardware_platform, &s, 0, 0) == 0) + static int mib[] = { CTL_HW, UNAME_HARDWARE_PLATFORM }; + if (sysctl (mib, 2, hardware_platform, &s, 0, 0) >= 0) element = hardware_platform; } #endif |