X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=app%2Ftest%2Fcommands.c;h=d48dd513d760303790e0a1c2ae20c5a0a20d4476;hb=f5ed2ea0ce8303592d16a3aa3fa60a7c0c4c2d5f;hp=94fbc310ed818b42e9815f6ff48d9a969733d303;hpb=a9de470cc7c0649221e156fc5f30a2dbdfe7c166;p=dpdk.git diff --git a/app/test/commands.c b/app/test/commands.c index 94fbc310ed..d48dd513d7 100644 --- a/app/test/commands.c +++ b/app/test/commands.c @@ -10,11 +10,6 @@ #include #include #include -#ifndef __linux__ -#ifndef __FreeBSD__ -#include -#endif -#endif #include #include #include @@ -44,6 +39,7 @@ #include #include #include +#include #include "test.h" @@ -63,8 +59,8 @@ struct cmd_autotest_result { }; static void cmd_autotest_parsed(void *parsed_result, - __attribute__((unused)) struct cmdline *cl, - __attribute__((unused)) void *data) + __rte_unused struct cmdline *cl, + __rte_unused void *data) { struct test_command *t; struct cmd_autotest_result *res = parsed_result; @@ -116,8 +112,8 @@ dump_struct_sizes(void) } static void cmd_dump_parsed(void *parsed_result, - __attribute__((unused)) struct cmdline *cl, - __attribute__((unused)) void *data) + __rte_unused struct cmdline *cl, + __rte_unused void *data) { struct cmd_dump_result *res = parsed_result; @@ -171,7 +167,7 @@ struct cmd_dump_one_result { }; static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl, - __attribute__((unused)) void *data) + __rte_unused void *data) { struct cmd_dump_one_result *res = parsed_result; @@ -220,9 +216,9 @@ struct cmd_quit_result { }; static void -cmd_quit_parsed(__attribute__((unused)) void *parsed_result, +cmd_quit_parsed(__rte_unused void *parsed_result, struct cmdline *cl, - __attribute__((unused)) void *data) + __rte_unused void *data) { cmdline_quit(cl); } @@ -249,7 +245,7 @@ struct cmd_set_rxtx_result { }; static void cmd_set_rxtx_parsed(void *parsed_result, struct cmdline *cl, - __attribute__((unused)) void *data) + __rte_unused void *data) { struct cmd_set_rxtx_result *res = parsed_result; if (test_set_rxtx_conf(res->mode) < 0) @@ -285,7 +281,7 @@ struct cmd_set_rxtx_anchor { static void cmd_set_rxtx_anchor_parsed(void *parsed_result, struct cmdline *cl, - __attribute__((unused)) void *data) + __rte_unused void *data) { struct cmd_set_rxtx_anchor *res = parsed_result; if (test_set_rxtx_anchor(res->type) < 0) @@ -322,7 +318,7 @@ struct cmd_set_rxtx_sc { static void cmd_set_rxtx_sc_parsed(void *parsed_result, struct cmdline *cl, - __attribute__((unused)) void *data) + __rte_unused void *data) { struct cmd_set_rxtx_sc *res = parsed_result; if (test_set_rxtx_sc(res->type) < 0) @@ -365,23 +361,22 @@ cmdline_parse_ctx_t main_ctx[] = { int commands_init(void) { struct test_command *t; - char *commands, *ptr; + char *commands; int commands_len = 0; TAILQ_FOREACH(t, &commands_list, next) { commands_len += strlen(t->command) + 1; } - commands = malloc(commands_len + 1); + commands = (char *)calloc(commands_len, sizeof(char)); if (!commands) return -1; - ptr = commands; TAILQ_FOREACH(t, &commands_list, next) { - ptr += sprintf(ptr, "%s#", t->command); + strlcat(commands, t->command, commands_len); + if (TAILQ_NEXT(t, next) != NULL) + strlcat(commands, "#", commands_len); } - ptr--; - ptr[0] = '\0'; cmd_autotest_autotest.string_data.str = commands; return 0;