From 39ecb61adefbf0313f7c48802f284adbe8f7e026 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Thu, 18 Aug 2022 00:41:41 +0800 Subject: [PATCH] event: pass "const struct option*" to spdk_app_parse_args() before this change, we cannot pass a `const struct option*` to spdk_app_parse_args() even the callee does not mutate the value pointed by the pointer. in other words, we are not able to write something like: static const option g_options[] = {...}; // ... spdk_app_parse_args(argc, argv, &opts, "", g_options, app_parse_arg, app_usage); after this change, the requirement of the type of the `option` argument is relaxed, so we can pass a `const struct option*` to this function now. Signed-off-by: Kefu Chai Change-Id: I8794fcf92090f538743850a28ef4a2a8c357f121 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14082 Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Tomasz Zawadzki --- include/spdk/event.h | 2 +- lib/event/app.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/spdk/event.h b/include/spdk/event.h index 19a4dd407..5f03d9df1 100644 --- a/include/spdk/event.h +++ b/include/spdk/event.h @@ -271,7 +271,7 @@ typedef enum spdk_app_parse_args_rvals spdk_app_parse_args_rvals_t; */ spdk_app_parse_args_rvals_t spdk_app_parse_args(int argc, char **argv, struct spdk_app_opts *opts, const char *getopt_str, - struct option *app_long_opts, int (*parse)(int ch, char *arg), + const struct option *app_long_opts, int (*parse)(int ch, char *arg), void (*usage)(void)); /** diff --git a/lib/event/app.c b/lib/event/app.c index d92774397..5b93bb968 100644 --- a/lib/event/app.c +++ b/lib/event/app.c @@ -743,7 +743,7 @@ usage(void (*app_usage)(void)) spdk_app_parse_args_rvals_t spdk_app_parse_args(int argc, char **argv, struct spdk_app_opts *opts, - const char *app_getopt_str, struct option *app_long_opts, + const char *app_getopt_str, const struct option *app_long_opts, int (*app_parse)(int ch, char *arg), void (*app_usage)(void)) {