Commit 658c80b2 authored by Kalwas, Jacek's avatar Kalwas, Jacek Committed by Tomasz Zawadzki
Browse files

event: make spdk_app_parse_args parse arg optional



Additionally align and improve interface description so it is clear
about what is optional (by current impl).

Additionally align err msg wording.

Change-Id: I51c43341d8ea6863f47c57d27fcb238b1be6b601
Signed-off-by: default avatarKalwas, Jacek <jacek.kalwas@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/19750


Community-CI: Mellanox Build Bot
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent a40cfb40
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -288,10 +288,12 @@ typedef enum spdk_app_parse_args_rvals spdk_app_parse_args_rvals_t;
 * \param opts Default options for the application.
 * \param getopt_str String representing the app-specific command line parameters.
 *        Characters in this string must not conflict with characters in SPDK_APP_GETOPT_STRING.
 * \param app_long_opts Array of full-name parameters. Can be NULL.
 *        This argument is optional.
 * \param app_long_opts Array of full-name parameters. This argument is optional.
 * \param parse Function pointer to call if an argument in getopt_str is found.
 *        This argument is optional but only if getopt_str is not provided.
 * \param usage Function pointer to print usage messages for app-specific command
 *		line parameters.
 *        line parameters. This argument is optional.
 *\return SPDK_APP_PARSE_ARGS_FAIL on failure, SPDK_APP_PARSE_ARGS_SUCCESS on
 *        success, SPDK_APP_PARSE_ARGS_HELP if '-h' passed as an option.
 */
+12 −2
Original line number Diff line number Diff line
@@ -1013,10 +1013,15 @@ spdk_app_parse_args(int argc, char **argv, struct spdk_app_opts *opts,
	if (app_getopt_str != NULL) {
		ch = app_opts_validate(app_getopt_str);
		if (ch) {
			SPDK_ERRLOG("Duplicated option '%c' between the generic and application specific spdk opts.\n",
			SPDK_ERRLOG("Duplicated option '%c' between app-specific command line parameter and generic spdk opts.\n",
				    ch);
			goto out;
		}

		if (!app_parse) {
			SPDK_ERRLOG("Parse function is required when app-specific command line parameters are provided.\n");
			goto out;
		}
	}

	cmdline_short_opts = spdk_sprintf_alloc("%s%s", app_getopt_str, SPDK_APP_GETOPT_STRING);
@@ -1255,9 +1260,14 @@ spdk_app_parse_args(int argc, char **argv, struct spdk_app_opts *opts,
			usage(app_usage);
			goto out;
		default:
			if (!app_parse) {
				SPDK_ERRLOG("Unsupported app-specific command line parameter '%c'.\n", ch);
				goto out;
			}

			rc = app_parse(ch, optarg);
			if (rc) {
				SPDK_ERRLOG("Parsing application specific arguments failed: %d\n", rc);
				SPDK_ERRLOG("Parsing app-specific command line parameter '%c' failed: %d\n", ch, rc);
				goto out;
			}
		}