From 2ef70ad7f692686710091132978129b614f6dd1a Mon Sep 17 00:00:00 2001 From: Volodymyr Vasiutyk Date: Wed, 6 Oct 2021 10:45:07 +0300 Subject: Early program termination only from main() --- CommandLine.c | 85 ++++++++++++++++++++++++++----------------------- CommandLine.h | 5 +++ darwin/Platform.c | 4 ++- darwin/Platform.h | 7 ++-- dragonflybsd/Platform.c | 3 +- dragonflybsd/Platform.h | 7 ++-- freebsd/Platform.c | 3 +- freebsd/Platform.h | 7 ++-- linux/Platform.c | 16 ++++++---- linux/Platform.h | 6 ++-- netbsd/Platform.c | 3 +- netbsd/Platform.h | 7 ++-- openbsd/Platform.c | 3 +- openbsd/Platform.h | 7 ++-- pcp/Platform.c | 25 ++++++++------- pcp/Platform.h | 5 +-- solaris/Platform.c | 3 +- solaris/Platform.h | 7 ++-- unsupported/Platform.c | 3 +- unsupported/Platform.h | 7 ++-- 20 files changed, 123 insertions(+), 90 deletions(-) diff --git a/CommandLine.c b/CommandLine.c index c48572c2..b2ad06e0 100644 --- a/CommandLine.c +++ b/CommandLine.c @@ -86,9 +86,9 @@ typedef struct CommandLineSettings_ { bool readonly; } CommandLineSettings; -static CommandLineSettings parseArguments(const char* program, int argc, char** argv) { +static CommandLineStatus parseArguments(const char* program, int argc, char** argv, CommandLineSettings* flags) { - CommandLineSettings flags = { + *flags = (CommandLineSettings) { .pidMatchList = NULL, .commFilter = NULL, .userId = (uid_t)-1, // -1 is guaranteed to be an invalid uid_t (see setreuid(2)) @@ -131,10 +131,10 @@ static CommandLineSettings parseArguments(const char* program, int argc, char** switch (opt) { case 'h': printHelpFlag(program); - exit(0); + return STATUS_OK_EXIT; case 'V': printVersionFlag(program); - exit(0); + return STATUS_OK_EXIT; case 's': assert(optarg); /* please clang analyzer, cause optarg can be NULL in the 'u' case */ if (String_eq(optarg, "help")) { @@ -143,29 +143,29 @@ static CommandLineSettings parseArguments(const char* program, int argc, char** const char* description = Process_fields[j].description; if (name) printf("%19s %s\n", name, description); } - exit(0); + return STATUS_OK_EXIT; } - flags.sortKey = 0; + flags->sortKey = 0; for (int j = 1; j < LAST_PROCESSFIELD; j++) { if (Process_fields[j].name == NULL) continue; if (String_eq(optarg, Process_fields[j].name)) { - flags.sortKey = j; + flags->sortKey = j; break; } } - if (flags.sortKey == 0) { + if (flags->sortKey == 0) { fprintf(stderr, "Error: invalid column \"%s\".\n", optarg); - exit(1); + return STATUS_ERROR_EXIT; } break; case 'd': - if (sscanf(optarg, "%16d", &(flags.delay)) == 1) { - if (flags.delay < 1) flags.delay = 1; - if (flags.delay > 100) flags.delay = 100; + if (sscanf(optarg, "%16d", &(flags->delay)) == 1) { + if (flags->delay < 1) flags->delay = 1; + if (flags->delay > 100) flags->delay = 100; } else { fprintf(stderr, "Error: invalid delay value \"%s\".\n", optarg); - exit(1); + return STATUS_ERROR_EXIT; } break; case 'u': @@ -177,30 +177,30 @@ static CommandLineSettings parseArguments(const char* program, int argc, char** } if (!username) { - flags.userId = geteuid(); - } else if (!Action_setUserOnly(username, &(flags.userId))) { + flags->userId = geteuid(); + } else if (!Action_setUserOnly(username, &(flags->userId))) { for (const char *itr = username; *itr; ++itr) if (!isdigit((unsigned char)*itr)) { fprintf(stderr, "Error: invalid user \"%s\".\n", username); - exit(1); + return STATUS_ERROR_EXIT; } - flags.userId = atol(username); + flags->userId = atol(username); } break; } case 'C': - flags.useColors = false; + flags->useColors = false; break; case 'M': #ifdef HAVE_GETMOUSE - flags.enableMouse = false; + flags->enableMouse = false; #endif break; case 'U': - flags.allowUnicode = false; + flags->allowUnicode = false; break; case 't': - flags.treeView = true; + flags->treeView = true; break; case 'p': { assert(optarg); /* please clang analyzer, cause optarg can be NULL in the 'u' case */ @@ -208,14 +208,14 @@ static CommandLineSettings parseArguments(const char* program, int argc, char** char* saveptr; const char* pid = strtok_r(argCopy, ",", &saveptr); - if (!flags.pidMatchList) { - flags.pidMatchList = Hashtable_new(8, false); + if (!flags->pidMatchList) { + flags->pidMatchList = Hashtable_new(8, false); } while(pid) { unsigned int num_pid = atoi(pid); - // deepcode ignore CastIntegerToAddress: we just want a non-NUll pointer here - Hashtable_put(flags.pidMatchList, num_pid, (void *) 1); + // deepcode ignore CastIntegerToAddress: we just want a non-NULL pointer here + Hashtable_put(flags->pidMatchList, num_pid, (void *) 1); pid = strtok_r(NULL, ",", &saveptr); } free(argCopy); @@ -224,7 +224,7 @@ static CommandLineSettings parseArguments(const char* program, int argc, char** } case 'F': { assert(optarg); - free_and_xStrdup(&flags.commFilter, optarg); + free_and_xStrdup(&flags->commFilter, optarg); break; } case 'H': { @@ -234,28 +234,30 @@ static CommandLineSettings parseArguments(const char* program, int argc, char** delay = argv[optind++]; } if (delay) { - if (sscanf(delay, "%16d", &(flags.highlightDelaySecs)) == 1) { - if (flags.highlightDelaySecs < 1) - flags.highlightDelaySecs = 1; + if (sscanf(delay, "%16d", &(flags->highlightDelaySecs)) == 1) { + if (flags->highlightDelaySecs < 1) + flags->highlightDelaySecs = 1; } else { fprintf(stderr, "Error: invalid highlight delay value \"%s\".\n", delay); - exit(1); + return STATUS_ERROR_EXIT; } } - flags.highlightChanges = true; + flags->highlightChanges = true; break; } case 128: - flags.readonly = true; + flags->readonly = true; break; - default: - if (Platform_getLongOption(opt, argc, argv) == false) - exit(1); - break; + default: { + CommandLineStatus status; + if ((status = Platform_getLongOption(opt, argc, argv)) != STATUS_OK) + return status; + break; + } } } - return flags; + return STATUS_OK; } static void CommandLine_delay(ProcessList* pl, unsigned long millisec) { @@ -288,12 +290,17 @@ int CommandLine_run(const char* name, int argc, char** argv) { else setlocale(LC_CTYPE, ""); - CommandLineSettings flags = parseArguments(name, argc, argv); + CommandLineStatus status = STATUS_OK; + CommandLineSettings flags = { 0 }; + + if ((status = parseArguments(name, argc, argv, &flags)) != STATUS_OK) + return status != STATUS_OK_EXIT ? 1 : 0; if (flags.readonly) Settings_enableReadonly(); - Platform_init(); + if (!Platform_init()) + return 1; Process_setupColumnWidths(); diff --git a/CommandLine.h b/CommandLine.h index 99579f5d..fbdede84 100644 --- a/CommandLine.h +++ b/CommandLine.h @@ -8,6 +8,11 @@ Released under the GNU GPLv2+, see the COPYING file in the source distribution for its full text. */ +typedef enum { + STATUS_OK, + STATUS_ERROR_EXIT, + STATUS_OK_EXIT +} CommandLineStatus; int CommandLine_run(const char* name, int argc, char** argv); diff --git a/darwin/Platform.c b/darwin/Platform.c index 3f596a39..152f617b 100644 --- a/darwin/Platform.c +++ b/darwin/Platform.c @@ -126,7 +126,7 @@ static double Platform_nanosecondsPerMachTick = 1.0; static double Platform_nanosecondsPerSchedulerTick = -1; -void Platform_init(void) { +bool Platform_init(void) { Platform_nanosecondsPerMachTick = Platform_calculateNanosecondsPerMachTick(); // Determine the number of scheduler clock ticks per second @@ -139,6 +139,8 @@ void Platform_init(void) { const double nanos_per_sec = 1e9; Platform_nanosecondsPerSchedulerTick = nanos_per_sec / scheduler_ticks_per_sec; + + return true; } // Converts ticks in the Mach "timebase" to nanoseconds. diff --git a/darwin/Platform.h b/darwin/Platform.h index c03a9b45..fe75db06 100644 --- a/darwin/Platform.h +++ b/darwin/Platform.h @@ -19,6 +19,7 @@ in the source distribution for its full text. #include "NetworkIOMeter.h" #include "ProcessLocksScreen.h" #include "SignalsPanel.h" +#include "CommandLine.h" #include "darwin/DarwinProcess.h" #include "generic/gettime.h" #include "generic/hostname.h" @@ -33,7 +34,7 @@ extern const unsigned int Platform_numberOfSignals; extern const MeterClass* const Platform_meterTypes[]; -void Platform_init(void); +bool Platform_init(void); // Converts ticks in the Mach "timebase" to nanoseconds. // See `mach_timebase_info`, as used to define the `Platform_nanosecondsPerMachTick` constant. @@ -87,8 +88,8 @@ static inline void Platform_getRelease(char** string) { static inline void Platform_longOptionsUsage(ATTR_UNUSED const char* name) { } -static inline bool Platform_getLongOption(ATTR_UNUSED int opt, ATTR_UNUSED int argc, ATTR_UNUSED char** argv) { - return false; +static inline CommandLineStatus Platform_getLongOption(ATTR_UNUSED int opt, ATTR_UNUSED int argc, ATTR_UNUSED char** argv) { + return STATUS_ERROR_EXIT; } static inline void Platform_gettime_realtime(struct timeval* tv, uint64_t* msec) { diff --git a/dragonflybsd/Platform.c b/dragonflybsd/Platform.c index bb603cb7..49414451 100644 --- a/dragonflybsd/Platform.c +++ b/dragonflybsd/Platform.c @@ -105,8 +105,9 @@ const MeterClass* const Platform_meterTypes[] = { NULL }; -void Platform_init(void) { +bool Platform_init(void) { /* no platform-specific setup needed */ + return true; } void Platform_done(void) { diff --git a/dragonflybsd/Platform.h b/dragonflybsd/Platform.h index f3f2ec5c..281a7ee0 100644 --- a/dragonflybsd/Platform.h +++ b/dragonflybsd/Platform.h @@ -23,6 +23,7 @@ in the source distribution for its full text. #include "Process.h" #include "ProcessLocksScreen.h" #include "SignalsPanel.h" +#include "CommandLine.h" #include "generic/gettime.h" #include "generic/hostname.h" #include "generic/uname.h" @@ -36,7 +37,7 @@ extern const unsigned int Platform_numberOfSignals; extern const MeterClass* const Platform_meterTypes[]; -void Platform_init(void); +bool Platform_init(void); void Platform_done(void); @@ -78,8 +79,8 @@ static inline void Platform_getRelease(char** string) { static inline void Platform_longOptionsUsage(ATTR_UNUSED const char* name) { } -static inline bool Platform_getLongOption(ATTR_UNUSED int opt, ATTR_UNUSED int argc, ATTR_UNUSED char** argv) { - return false; +static inline CommandLineStatus Platform_getLongOption(ATTR_UNUSED int opt, ATTR_UNUSED int argc, ATTR_UNUSED char** argv) { + return STATUS_ERROR_EXIT; } static inline void Platform_gettime_realtime(struct timeval* tv, uint64_t* msec) { diff --git a/freebsd/Platform.c b/freebsd/Platform.c index 78ed9bb8..6c82bc24 100644 --- a/freebsd/Platform.c +++ b/freebsd/Platform.c @@ -127,8 +127,9 @@ const MeterClass* const Platform_meterTypes[] = { NULL }; -void Platform_init(void) { +bool Platform_init(void) { /* no platform-specific setup needed */ + return true; } void Platform_done(void) { diff --git a/freebsd/Platform.h b/freebsd/Platform.h index e99232e9..a1aa31bc 100644 --- a/freebsd/Platform.h +++ b/freebsd/Platform.h @@ -19,6 +19,7 @@ in the source distribution for its full text. #include "Process.h" #include "ProcessLocksScreen.h" #include "SignalsPanel.h" +#include "CommandLine.h" #include "generic/gettime.h" #include "generic/hostname.h" #include "generic/uname.h" @@ -32,7 +33,7 @@ extern const unsigned int Platform_numberOfSignals; extern const MeterClass* const Platform_meterTypes[]; -void Platform_init(void); +bool Platform_init(void); void Platform_done(void); @@ -78,8 +79,8 @@ static inline void Platform_getRelease(char** string) { static inline void Platform_longOptionsUsage(ATTR_UNUSED const char* name) { } -static inline bool Platform_getLongOption(ATTR_UNUSED int opt, ATTR_UNUSED int argc, ATTR_UNUSED char** argv) { - return false; +static inline CommandLineStatus Platform_getLongOption(ATTR_UNUSED int opt, ATTR_UNUSED int argc, ATTR_UNUSED char** argv) { + return STATUS_ERROR_EXIT; } static inline void Platform_gettime_realtime(struct timeval* tv, uint64_t* msec) { diff --git a/linux/Platform.c b/linux/Platform.c index e7f3d8f0..93953e86 100644 --- a/linux/Platform.c +++ b/linux/Platform.c @@ -835,7 +835,7 @@ void Platform_longOptionsUsage(const char* name) #endif } -bool Platform_getLongOption(int opt, int argc, char** argv) { +CommandLineStatus Platform_getLongOption(int opt, int argc, char** argv) { #ifndef HAVE_LIBCAP (void) argc; (void) argv; @@ -858,16 +858,16 @@ bool Platform_getLongOption(int opt, int argc, char** argv) { Platform_capabilitiesMode = CAP_MODE_STRICT; } else { fprintf(stderr, "Error: invalid capabilities mode \"%s\".\n", mode); - exit(1); + return STATUS_ERROR_EXIT; } - return true; + return STATUS_OK; } #endif default: break; } - return false; + return STATUS_ERROR_EXIT; } #ifdef HAVE_LIBCAP @@ -956,20 +956,22 @@ static int dropCapabilities(enum CapMode mode) { } #endif -void Platform_init(void) { +bool Platform_init(void) { #ifdef HAVE_LIBCAP if (dropCapabilities(Platform_capabilitiesMode) < 0) - exit(1); + return false; #endif if (access(PROCDIR, R_OK) != 0) { fprintf(stderr, "Error: could not read procfs (compiled to look in %s).\n", PROCDIR); - exit(1); + return false; } #ifdef HAVE_SENSORS_SENSORS_H LibSensors_init(); #endif + + return true; } void Platform_done(void) { diff --git a/linux/Platform.h b/linux/Platform.h index 9c4e65d4..2e2fb3e6 100644 --- a/linux/Platform.h +++ b/linux/Platform.h @@ -27,6 +27,7 @@ in the source distribution for its full text. #include "ProcessLocksScreen.h" #include "RichString.h" #include "SignalsPanel.h" +#include "CommandLine.h" #include "generic/gettime.h" #include "generic/hostname.h" #include "generic/uname.h" @@ -45,8 +46,7 @@ extern const unsigned int Platform_numberOfSignals; extern const MeterClass* const Platform_meterTypes[]; -void Platform_init(void); - +bool Platform_init(void); void Platform_done(void); void Platform_setBindings(Htop_Action* keys); @@ -100,7 +100,7 @@ static inline void Platform_getRelease(char** string) { void Platform_longOptionsUsage(const char* name); -bool Platform_getLongOption(int opt, int argc, char** argv); +CommandLineStatus Platform_getLongOption(int opt, int argc, char** argv); static inline void Platform_gettime_realtime(struct timeval* tv, uint64_t* msec) { Generic_gettime_realtime(tv, msec); diff --git a/netbsd/Platform.c b/netbsd/Platform.c index ac814642..3b27548d 100644 --- a/netbsd/Platform.c +++ b/netbsd/Platform.c @@ -174,8 +174,9 @@ const MeterClass* const Platform_meterTypes[] = { NULL }; -void Platform_init(void) { +bool Platform_init(void) { /* no platform-specific setup needed */ + return true; } void Platform_done(void) { diff --git a/netbsd/Platform.h b/netbsd/Platform.h index 1d1115e7..e650bcda 100644 --- a/netbsd/Platform.h +++ b/netbsd/Platform.h @@ -24,6 +24,7 @@ in the source distribution for its full text. #include "Process.h" #include "ProcessLocksScreen.h" #include "SignalsPanel.h" +#include "CommandLine.h" #include "generic/gettime.h" #include "generic/hostname.h" #include "generic/uname.h" @@ -42,7 +43,7 @@ extern const unsigned int Platform_numberOfSignals; extern const MeterClass* const Platform_meterTypes[]; -void Platform_init(void); +bool Platform_init(void); void Platform_done(void); @@ -82,8 +83,8 @@ static inline void Platform_getRelease(char** string) { static inline void Platform_longOptionsUsage(ATTR_UNUSED const char* name) { } -static inline bool Platform_getLongOption(ATTR_UNUSED int opt, ATTR_UNUSED int argc, ATTR_UNUSED char** argv) { - return false; +static inline CommandLineStatus Platform_getLongOption(ATTR_UNUSED int opt, ATTR_UNUSED int argc, ATTR_UNUSED char** argv) { + return STATUS_ERROR_EXIT; } static inline void Platform_gettime_realtime(struct timeval* tv, uint64_t* msec) { diff --git a/openbsd/Platform.c b/openbsd/Platform.c index b941ba75..15467e13 100644 --- a/openbsd/Platform.c +++ b/openbsd/Platform.c @@ -121,8 +121,9 @@ const MeterClass* const Platform_meterTypes[] = { NULL }; -void Platform_init(void) { +bool Platform_init(void) { /* no platform-specific setup needed */ + return true; } void Platform_done(void) { diff --git a/openbsd/Platform.h b/openbsd/Platform.h index b6823b50..fd6a6575 100644 --- a/openbsd/Platform.h +++ b/openbsd/Platform.h @@ -20,6 +20,7 @@ in the source distribution for its full text. #include "Process.h" #include "ProcessLocksScreen.h" #include "SignalsPanel.h" +#include "CommandLine.h" #include "generic/gettime.h" #include "generic/hostname.h" #include "generic/uname.h" @@ -34,7 +35,7 @@ extern const unsigned int Platform_numberOfSignals; extern const MeterClass* const Platform_meterTypes[]; -void Platform_init(void); +bool Platform_init(void); void Platform_done(void); @@ -76,8 +77,8 @@ static inline void Platform_getRelease(char** string) { static inline void Platform_longOptionsUsage(ATTR_UNUSED const char* name) { } -static inline bool Platform_getLongOption(ATTR_UNUSED int opt, ATTR_UNUSED int argc, ATTR_UNUSED char** argv) { - return false; +static inline CommandLineStatus Platform_getLongOption(ATTR_UNUSED int opt, ATTR_UNUSED int argc, ATTR_UNUSED char** argv) { + return STATUS_ERROR_EXIT; } static inline void Platform_gettime_realtime(struct timeval* tv, uint64_t* msec) { diff --git a/pcp/Platform.c b/pcp/Platform.c index cd7b1f48..150660af 100644 --- a/pcp/Platform.c +++ b/pcp/Platform.c @@ -257,7 +257,7 @@ size_t Platform_addMetric(PCPMetric id, const char* name) { /* global state from the environment and command line arguments */ pmOptions opts; -void Platform_init(void) { +bool Platform_init(void) { const char* source; if (opts.context == PM_CONTEXT_ARCHIVE) { source = opts.archives[0]; @@ -277,12 +277,12 @@ void Platform_init(void) { } if (sts < 0) { fprintf(stderr, "Cannot setup PCP metric source: %s\n", pmErrStr(sts)); - exit(1); + return false; } /* setup timezones and other general startup preparation completion */ if (pmGetContextOptions(sts, &opts) < 0 || opts.errors) { pmflush(); - exit(1); + return false; } pcp = xCalloc(1, sizeof(Platform)); @@ -309,7 +309,8 @@ void Platform_init(void) { sts = pmLookupName(pcp->totalMetrics, pcp->names, pcp->pmids); if (sts < 0) { fprintf(stderr, "Error: cannot lookup metric names: %s\n", pmErrStr(sts)); - exit(1); + Platform_done(); + return false; } for (size_t i = 0; i < pcp->totalMetrics; i++) { @@ -361,6 +362,8 @@ void Platform_init(void) { Platform_getRelease(0); Platform_getMaxCPU(); Platform_getMaxPid(); + + return true; } void Platform_dynamicColumnsDone(Hashtable* columns) { @@ -697,16 +700,16 @@ void Platform_longOptionsUsage(ATTR_UNUSED const char* name) { " --timezone=TZ set reporting timezone\n"); } -bool Platform_getLongOption(int opt, ATTR_UNUSED int argc, char** argv) { +CommandLineStatus Platform_getLongOption(int opt, ATTR_UNUSED int argc, char** argv) { /* libpcp export without a header definition */ extern void __pmAddOptHost(pmOptions*, char*); switch (opt) { case PLATFORM_LONGOPT_HOST: /* --host=HOSTSPEC */ if (argv[optind][0] == '\0') - return false; + return STATUS_ERROR_EXIT; __pmAddOptHost(&opts, optarg); - return true; + return STATUS_OK; case PLATFORM_LONGOPT_HOSTZONE: /* --hostzone */ if (opts.timezone) { @@ -715,23 +718,23 @@ bool Platform_getLongOption(int opt, ATTR_UNUSED int argc, char** argv) { } else { opts.tzflag = 1; } - return true; + return STATUS_OK; case PLATFORM_LONGOPT_TIMEZONE: /* --timezone=TZ */ if (argv[optind][0] == '\0') - return false; + return STATUS_ERROR_EXIT; if (opts.tzflag) { pmprintf("%s: at most one of -Z and -z allowed\n", pmGetProgname()); opts.errors++; } else { opts.timezone = optarg; } - return true; + return STATUS_OK; default: break; } - return false; + return STATUS_ERROR_EXIT; } void Platform_gettime_realtime(struct timeval* tv, uint64_t* msec) { diff --git a/pcp/Platform.h b/pcp/Platform.h index 37a87996..ad38cbbd 100644 --- a/pcp/Platform.h +++ b/pcp/Platform.h @@ -34,6 +34,7 @@ in the source distribution for its full text. #include "ProcessLocksScreen.h" #include "RichString.h" #include "SignalsPanel.h" +#include "CommandLine.h" #include "pcp/PCPDynamicColumn.h" #include "pcp/PCPDynamicMeter.h" @@ -67,7 +68,7 @@ extern const unsigned int Platform_numberOfSignals; extern const MeterClass* const Platform_meterTypes[]; -void Platform_init(void); +bool Platform_init(void); void Platform_done(void); @@ -126,7 +127,7 @@ enum { void Platform_longOptionsUsage(const char* name); -bool Platform_getLongOption(int opt, int argc, char** argv); +CommandLineStatus Platform_getLongOption(int opt, int argc, char** argv); extern pmOptions opts; diff --git a/solaris/Platform.c b/solaris/Platform.c index eabbab59..cdc79ae4 100644 --- a/solaris/Platform.c +++ b/solaris/Platform.c @@ -122,8 +122,9 @@ const MeterClass* const Platform_meterTypes[] = { NULL }; -void Platform_init(void) { +bool Platform_init(void) { /* no platform-specific setup needed */ + return true; } void Platform_done(void) { diff --git a/solaris/Platform.h b/solaris/Platform.h index a60b9784..b140788d 100644 --- a/solaris/Platform.h +++ b/solaris/Platform.h @@ -35,6 +35,7 @@ in the source distribution for its full text. #include "NetworkIOMeter.h" #include "ProcessLocksScreen.h" #include "SignalsPanel.h" +#include "CommandLine.h" #include "generic/gettime.h" #include "generic/hostname.h" #include "generic/uname.h" @@ -59,7 +60,7 @@ extern const ProcessField Platform_defaultFields[]; extern const MeterClass* const Platform_meterTypes[]; -void Platform_init(void); +bool Platform_init(void); void Platform_done(void); @@ -105,8 +106,8 @@ static inline void Platform_getRelease(char** string) { static inline void Platform_longOptionsUsage(ATTR_UNUSED const char* name) { } -static inline bool Platform_getLongOption(ATTR_UNUSED int opt, ATTR_UNUSED int argc, ATTR_UNUSED char** argv) { - return false; +static inline CommandLineStatus Platform_getLongOption(ATTR_UNUSED int opt, ATTR_UNUSED int argc, ATTR_UNUSED char** argv) { + return STATUS_ERROR_EXIT; } static inline void Platform_gettime_realtime(struct timeval* tv, uint64_t* msec) { diff --git a/unsupported/Platform.c b/unsupported/Platform.c index 9be56ea6..e55de4ab 100644 --- a/unsupported/Platform.c +++ b/unsupported/Platform.c @@ -68,8 +68,9 @@ const MeterClass* const Platform_meterTypes[] = { static const char Platform_unsupported[] = "unsupported"; -void Platform_init(void) { +bool Platform_init(void) { /* no platform-specific setup needed */ + return true; } void Platform_done(void) { diff --git a/unsupported/Platform.h b/unsupported/Platform.h index ace7aae1..7f4ad9ab 100644 --- a/unsupported/Platform.h +++ b/unsupported/Platform.h @@ -15,6 +15,7 @@ in the source distribution for its full text. #include "NetworkIOMeter.h" #include "ProcessLocksScreen.h" #include "SignalsPanel.h" +#include "CommandLine.h" #include "generic/gettime.h" #include "unsupported/UnsupportedProcess.h" @@ -27,7 +28,7 @@ extern const ProcessField Platform_defaultFields[]; extern const MeterClass* const Platform_meterTypes[]; -void Platform_init(void); +bool Platform_init(void); void Platform_done(void); @@ -65,8 +66,8 @@ void Platform_getRelease(char** string); static inline void Platform_longOptionsUsage(ATTR_UNUSED const char* name) { } -static inline bool Platform_getLongOption(ATTR_UNUSED int opt, ATTR_UNUSED int argc, ATTR_UNUSED char** argv) { - return false; +static inline CommandLineStatus Platform_getLongOption(ATTR_UNUSED int opt, ATTR_UNUSED int argc, ATTR_UNUSED char** argv) { + return STATUS_ERROR_EXIT; } static inline void Platform_gettime_realtime(struct timeval* tv, uint64_t* msec) { -- cgit v1.2.3