diff options
author | Tuukka Tikkanen <tuukka.tikkanen@linaro.org> | 2014-12-10 14:16:06 +0200 |
---|---|---|
committer | Tuukka Tikkanen <tuukka.tikkanen@linaro.org> | 2014-12-12 08:57:27 +0200 |
commit | f18b1b7a4df9dec114386d9839a2c1e408fb0556 (patch) | |
tree | fae4aa046536de8b900177a51f3e951cfe2d4a10 | |
parent | ffff381eadc10ee8a23bcf96ddac1c81b67d7fdd (diff) |
report_ops: Add mechanism for report_ops to check program options
Some reports may require some program options to be set, but other
reports may not require the same options. To keep details of these
checks out of main() and getoptions(), this patch adds a new
operation to report_ops for doing these checks when necessary.
Pointer to struct program_options is passed to the op. If the
options are not suitable for operation, the op must print an error
message for the user and return -1. Otherwise the op should
return 0.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
-rw-r--r-- | idlestat.c | 3 | ||||
-rw-r--r-- | report_ops.h | 1 |
2 files changed, 4 insertions, 0 deletions
@@ -1491,6 +1491,9 @@ int main(int argc, char *argv[], char *const envp[]) } output_handler = options.report_ops; + if (output_handler->check_options && + output_handler->check_options(&options) < 0) + return 1; if (output_handler->check_output(&options, options.report_data)) return 1; diff --git a/report_ops.h b/report_ops.h index eef79bc..fe6100e 100644 --- a/report_ops.h +++ b/report_ops.h @@ -7,6 +7,7 @@ struct cpufreq_pstate; struct wakeup_irq; struct report_ops { + int (*check_options)(struct program_options *); int (*check_output)(struct program_options *, void *); int (*open_report_file)(char *path, void *); |