test/unit: fix scan-build errors in the event tests
Change-Id: I459c8cdea080af24374c2ad1fa42e291c5021840 Signed-off-by: Seth Howell <seth.howell@intel.com> Reviewed-on: https://review.gerrithub.io/423950 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
parent
438b71d17e
commit
14ccaed6de
@ -117,12 +117,13 @@ test_spdk_app_parse_args(void)
|
||||
};
|
||||
|
||||
/* Test valid arguments. Expected result: PASS */
|
||||
rc = spdk_app_parse_args(test_argc, valid_argv, &opts, "", NULL, NULL, NULL);
|
||||
rc = spdk_app_parse_args(test_argc, valid_argv, &opts, "", NULL, unittest_parse_args, NULL);
|
||||
CU_ASSERT_EQUAL(rc, SPDK_APP_PARSE_ARGS_SUCCESS);
|
||||
optind = 1;
|
||||
|
||||
/* Test invalid short option Expected result: FAIL */
|
||||
rc = spdk_app_parse_args(test_argc, argv_added_short_opt, &opts, "", NULL, NULL, NULL);
|
||||
rc = spdk_app_parse_args(test_argc, argv_added_short_opt, &opts, "", NULL, unittest_parse_args,
|
||||
NULL);
|
||||
CU_ASSERT_EQUAL(rc, SPDK_APP_PARSE_ARGS_FAIL);
|
||||
optind = 1;
|
||||
|
||||
@ -133,7 +134,8 @@ test_spdk_app_parse_args(void)
|
||||
optind = 1;
|
||||
|
||||
/* Test invalid long option Expected result: FAIL */
|
||||
rc = spdk_app_parse_args(test_argc, argv_added_long_opt, &opts, "", NULL, NULL, NULL);
|
||||
rc = spdk_app_parse_args(test_argc, argv_added_long_opt, &opts, "", NULL, unittest_parse_args,
|
||||
NULL);
|
||||
CU_ASSERT_EQUAL(rc, SPDK_APP_PARSE_ARGS_FAIL);
|
||||
optind = 1;
|
||||
|
||||
@ -145,7 +147,8 @@ test_spdk_app_parse_args(void)
|
||||
optind = 1;
|
||||
|
||||
/* Test overlapping global and local options. Expected result: FAIL */
|
||||
rc = spdk_app_parse_args(test_argc, valid_argv, &opts, SPDK_APP_GETOPT_STRING, NULL, NULL, NULL);
|
||||
rc = spdk_app_parse_args(test_argc, valid_argv, &opts, SPDK_APP_GETOPT_STRING, NULL,
|
||||
unittest_parse_args, NULL);
|
||||
CU_ASSERT_EQUAL(rc, SPDK_APP_PARSE_ARGS_FAIL);
|
||||
optind = 1;
|
||||
|
||||
@ -153,17 +156,18 @@ test_spdk_app_parse_args(void)
|
||||
for (i = 0; i < SPDK_APP_MAX_CMDLINE_OPTIONS; i++) {
|
||||
my_options[i].name = name_teaser;
|
||||
}
|
||||
rc = spdk_app_parse_args(test_argc, valid_argv, &opts, "", my_options, NULL, NULL);
|
||||
rc = spdk_app_parse_args(test_argc, valid_argv, &opts, "", my_options, unittest_parse_args, NULL);
|
||||
CU_ASSERT_EQUAL(rc, SPDK_APP_PARSE_ARGS_FAIL);
|
||||
optind = 1;
|
||||
|
||||
/* Specify -B and -W options at the same time. Expected result: FAIL */
|
||||
rc = spdk_app_parse_args(test_argc, invalid_argv_BW, &opts, "", NULL, NULL, NULL);
|
||||
rc = spdk_app_parse_args(test_argc, invalid_argv_BW, &opts, "", NULL, unittest_parse_args, NULL);
|
||||
CU_ASSERT_EQUAL(rc, SPDK_APP_PARSE_ARGS_FAIL);
|
||||
optind = 1;
|
||||
|
||||
/* Omit necessary argument to option */
|
||||
rc = spdk_app_parse_args(test_argc, invalid_argv_missing_option, &opts, "", NULL, NULL, NULL);
|
||||
rc = spdk_app_parse_args(test_argc, invalid_argv_missing_option, &opts, "", NULL,
|
||||
unittest_parse_args, NULL);
|
||||
CU_ASSERT_EQUAL(rc, SPDK_APP_PARSE_ARGS_FAIL);
|
||||
optind = 1;
|
||||
}
|
||||
|
@ -75,8 +75,12 @@ spdk_event_allocate(uint32_t core, spdk_event_fn fn, void *arg1, void *arg2)
|
||||
|
||||
void spdk_event_call(struct spdk_event *event)
|
||||
{
|
||||
event->fn(event->arg1, event->arg2);
|
||||
free(event);
|
||||
if (event != NULL) {
|
||||
if (event->fn != NULL) {
|
||||
event->fn(event->arg1, event->arg2);
|
||||
}
|
||||
free(event);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user