aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTuukka Tikkanen <tuukka.tikkanen@linaro.org>2014-12-10 14:16:06 +0200
committerTuukka Tikkanen <tuukka.tikkanen@linaro.org>2014-12-12 08:57:27 +0200
commitf18b1b7a4df9dec114386d9839a2c1e408fb0556 (patch)
treefae4aa046536de8b900177a51f3e951cfe2d4a10
parentffff381eadc10ee8a23bcf96ddac1c81b67d7fdd (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.c3
-rw-r--r--report_ops.h1
2 files changed, 4 insertions, 0 deletions
diff --git a/idlestat.c b/idlestat.c
index 3020a47..228c67a 100644
--- a/idlestat.c
+++ b/idlestat.c
@@ -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 *);