Skip to content

Commit

Permalink
remove warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
marcinbor85 committed Jan 12, 2025
1 parent f13f2b2 commit 7d02757
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 23 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ CLIP_DEF_ROOT_COMMAND(g_adc_cmd, "adc", "control adc driver", NULL)
CLIP_DEF_COMMAND("read", "read input", adc_read_callback) CLIP_DEF_WITH_ARGS()
/* there will be 1 required argument in "adc read" command */
CLIP_DEF_ARGUMENT("channel", "channel number", CLIP_ARG_TYPE_UINT)
CLIP_DEF_COMMAND_END()
CLIP_DEF_COMMAND_END_WITH_ARGS()
CLIP_DEF_COMMAND("set", "set reference", adc_set_callback) CLIP_DEF_WITH_ARGS()
/* there will be 1 required argument in "adc set" command */
CLIP_DEF_ARGUMENT("vref", "voltage reference", CLIP_ARG_TYPE_FLOAT)
CLIP_DEF_COMMAND_END()
CLIP_DEF_COMMAND_END_WITH_ARGS()
CLIP_DEF_COMMAND("start", "start sampling", adc_start_callback) CLIP_DEF_COMMAND_END()
CLIP_DEF_COMMAND("stop", "stop sampling", adc_stop_callback) CLIP_DEF_COMMAND_END()
CLIP_DEF_ROOT_COMMAND_END()
Expand All @@ -131,24 +131,24 @@ CLIP_DEF_ROOT_COMMAND(g_gpio_cmd, "gpio", "control gpio", NULL)
CLIP_DEF_COMMAND("pin", "get pin state", gpio_get_pin_callback) CLIP_DEF_WITH_ARGS()
/* there will be 1 required argument in "gpio get pin" command */
CLIP_DEF_ARGUMENT("pin", "pin number", CLIP_ARG_TYPE_UINT)
CLIP_DEF_COMMAND_END()
CLIP_DEF_COMMAND_END_WITH_ARGS()
CLIP_DEF_COMMAND("reg", "get register value", gpio_get_reg_callback) CLIP_DEF_WITH_ARGS()
/* there will be 1 required argument in "gpio get reg" command */
CLIP_DEF_ARGUMENT("address", "register address", CLIP_ARG_TYPE_UINT)
CLIP_DEF_COMMAND_END()
CLIP_DEF_COMMAND_END_WITH_ARGS()
CLIP_DEF_COMMAND_END()
CLIP_DEF_COMMAND("set", "set methods", NULL)
/* there will be 2 subcommands: pin, reg */
CLIP_DEF_COMMAND("pin", "set pin state", gpio_set_pin_callback) CLIP_DEF_WITH_ARGS()
/* there will be 2 required arguments in "gpio set pin" command */
CLIP_DEF_ARGUMENT("pin", "pin number", CLIP_ARG_TYPE_UINT)
CLIP_DEF_ARGUMENT("state", "pin state", CLIP_ARG_TYPE_UINT)
CLIP_DEF_COMMAND_END()
CLIP_DEF_COMMAND_END_WITH_ARGS()
CLIP_DEF_COMMAND("reg", "set register value", gpio_set_reg_callback) CLIP_DEF_WITH_ARGS()
/* there will be 2 required arguments in "gpio set reg" command */
CLIP_DEF_ARGUMENT("address", "register address", CLIP_ARG_TYPE_UINT)
CLIP_DEF_ARGUMENT("value", "register value", CLIP_ARG_TYPE_UINT)
CLIP_DEF_COMMAND_END()
CLIP_DEF_COMMAND_END_WITH_ARGS()
CLIP_DEF_COMMAND_END()
CLIP_DEF_ROOT_COMMAND_END()

Expand All @@ -159,12 +159,12 @@ CLIP_DEF_ROOT_COMMAND(g_mem_cmd, "mem", "memory driver", NULL)
/* there will be 2 required arguments in "mem write" command */
CLIP_DEF_ARGUMENT("address", "address to write", CLIP_ARG_TYPE_UINT)
CLIP_DEF_ARGUMENT("data", "binary data to write", CLIP_ARG_TYPE_HEXARRAY)
CLIP_DEF_COMMAND_END()
CLIP_DEF_COMMAND_END_WITH_ARGS()
CLIP_DEF_COMMAND("read", "read data from memory", mem_read_callback) CLIP_DEF_WITH_ARGS()
/* there will be 2 required arguments in "mem read" command */
CLIP_DEF_ARGUMENT("address", "address to read", CLIP_ARG_TYPE_UINT)
CLIP_DEF_ARGUMENT("size", "number of bytes to read", CLIP_ARG_TYPE_UINT)
CLIP_DEF_COMMAND_END()
CLIP_DEF_COMMAND_END_WITH_ARGS()
CLIP_DEF_ROOT_COMMAND_END()

/* Definition of command: exit */
Expand Down
6 changes: 3 additions & 3 deletions examples/BasicCLI/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ SOFTWARE.
CLIP_DEF_ROOT_COMMAND(g_cli_gpio_cmd, "gpio", "control gpio", NULL)
CLIP_DEF_COMMAND("get", "get pin state", cli_gpio_get_callback) CLIP_DEF_WITH_ARGS()
CLIP_DEF_ARGUMENT("pin", "pin number", CLIP_ARG_TYPE_UINT)
CLIP_DEF_COMMAND_END()
CLIP_DEF_COMMAND_END_WITH_ARGS()
CLIP_DEF_COMMAND("set", "set pin state", cli_gpio_set_callback) CLIP_DEF_WITH_ARGS()
CLIP_DEF_ARGUMENT("pin", "pin number", CLIP_ARG_TYPE_UINT)
CLIP_DEF_ARGUMENT("state", "pin state", CLIP_ARG_TYPE_UINT)
CLIP_DEF_COMMAND_END()
CLIP_DEF_COMMAND_END_WITH_ARGS()
CLIP_DEF_ROOT_COMMAND_END()

CLIP_DEF_ROOT_COMMAND(g_cli_echo_cmd, "echo", "echo command", cli_echo_callback) CLIP_DEF_WITH_ARGS()
CLIP_DEF_ARGUMENT("text", "text to print", CLIP_ARG_TYPE_STRING)
CLIP_DEF_ROOT_COMMAND_END()
CLIP_DEF_ROOT_COMMAND_END_WITH_ARGS()

CLIP_DEF_ROOT(g_cli_clip, NULL, cli_event_callback)
CLIP_DEF_ADD_ROOT_COMMAND(&g_cli_gpio_cmd)
Expand Down
4 changes: 2 additions & 2 deletions examples/linux/src/adc.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ CLIP_DEF_ROOT_COMMAND(g_adc_cmd, "adc", "control adc driver", NULL)

CLIP_DEF_COMMAND("read", "read input", adc_read_callback) CLIP_DEF_WITH_ARGS()
CLIP_DEF_ARGUMENT("channel", "channel number", CLIP_ARG_TYPE_UINT)
CLIP_DEF_COMMAND_END()
CLIP_DEF_COMMAND_END_WITH_ARGS()

CLIP_DEF_COMMAND("set", "set reference", adc_set_callback) CLIP_DEF_WITH_ARGS()
CLIP_DEF_ARGUMENT("vref", "voltage reference", CLIP_ARG_TYPE_FLOAT)
CLIP_DEF_COMMAND_END()
CLIP_DEF_COMMAND_END_WITH_ARGS()

CLIP_DEF_COMMAND("start", "start sampling", adc_start_callback) CLIP_DEF_COMMAND_END()
CLIP_DEF_COMMAND("stop", "stop sampling", adc_stop_callback) CLIP_DEF_COMMAND_END()
Expand Down
8 changes: 4 additions & 4 deletions examples/linux/src/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,23 +65,23 @@ CLIP_DEF_ROOT_COMMAND(g_gpio_cmd, "gpio", "control gpio", NULL)
CLIP_DEF_COMMAND("get", "get methods", NULL)
CLIP_DEF_COMMAND("pin", "get pin state", gpio_get_pin_callback) CLIP_DEF_WITH_ARGS()
CLIP_DEF_ARGUMENT("pin", "pin number", CLIP_ARG_TYPE_UINT)
CLIP_DEF_COMMAND_END()
CLIP_DEF_COMMAND_END_WITH_ARGS()

CLIP_DEF_COMMAND("reg", "get register value", gpio_get_reg_callback) CLIP_DEF_WITH_ARGS()
CLIP_DEF_ARGUMENT("address", "register address", CLIP_ARG_TYPE_UINT)
CLIP_DEF_COMMAND_END()
CLIP_DEF_COMMAND_END_WITH_ARGS()
CLIP_DEF_COMMAND_END()

CLIP_DEF_COMMAND("set", "set methods", NULL)
CLIP_DEF_COMMAND("pin", "set pin state", gpio_set_pin_callback) CLIP_DEF_WITH_ARGS()
CLIP_DEF_ARGUMENT("pin", "pin number", CLIP_ARG_TYPE_UINT)
CLIP_DEF_ARGUMENT("state", "pin state", CLIP_ARG_TYPE_UINT)
CLIP_DEF_COMMAND_END()
CLIP_DEF_COMMAND_END_WITH_ARGS()

CLIP_DEF_COMMAND("reg", "set register value", gpio_set_reg_callback) CLIP_DEF_WITH_ARGS()
CLIP_DEF_ARGUMENT("address", "register address", CLIP_ARG_TYPE_UINT)
CLIP_DEF_ARGUMENT("value", "register value", CLIP_ARG_TYPE_UINT)
CLIP_DEF_COMMAND_END()
CLIP_DEF_COMMAND_END_WITH_ARGS()

CLIP_DEF_COMMAND_END()

Expand Down
4 changes: 2 additions & 2 deletions examples/linux/src/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ CLIP_DEF_ROOT_COMMAND(g_mem_cmd, "mem", "memory driver", NULL)
CLIP_DEF_COMMAND("write", "write data to memory", mem_write_callback) CLIP_DEF_WITH_ARGS()
CLIP_DEF_ARGUMENT("address", "address to write", CLIP_ARG_TYPE_UINT)
CLIP_DEF_ARGUMENT("data", "binary data to write", CLIP_ARG_TYPE_HEXARRAY)
CLIP_DEF_COMMAND_END()
CLIP_DEF_COMMAND_END_WITH_ARGS()

CLIP_DEF_COMMAND("read", "read data from memory", mem_read_callback) CLIP_DEF_WITH_ARGS()
CLIP_DEF_ARGUMENT("address", "address to read", CLIP_ARG_TYPE_UINT)
CLIP_DEF_ARGUMENT("size", "number of bytes to read", CLIP_ARG_TYPE_UINT)
CLIP_DEF_COMMAND_END()
CLIP_DEF_COMMAND_END_WITH_ARGS()

CLIP_DEF_ROOT_COMMAND_END()
1 change: 0 additions & 1 deletion src/clip_cmd_call.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ void clip_cmd_call_command_callback(const struct clip *self, const struct clip_c
av->val_str = arg;

const struct clip_arg *ca = NULL;
char *end_arg = NULL;
if (no_more_required_args == false && cmd->args != NULL) {
ca = cmd->args[argc];
if (ca != NULL) {
Expand Down
18 changes: 16 additions & 2 deletions src/clip_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,18 @@ const struct clip_command var_name = {\
_CLIP_DEF_COMMAND(cmd_name, cmd_description, callback_func)\

///< public macro for finishing root command definition
#define CLIP_DEF_ROOT_COMMAND_END()\
#define CLIP_DEF_ROOT_COMMAND_END_WITH_ARGS()\
NULL,\
}\
};\

///< public macro for finishing root command without args definition
#define CLIP_DEF_ROOT_COMMAND_END()\
NULL,\
},\
.args = NULL\
};\

///< public macro for defining command
#define CLIP_DEF_COMMAND(cmd_name, cmd_description, callback_func)\
&(const struct clip_command) {\
Expand All @@ -67,11 +74,18 @@ const struct clip_command var_name = {\
},\

///< public macro for finishing command definition
#define CLIP_DEF_COMMAND_END()\
#define CLIP_DEF_COMMAND_END_WITH_ARGS()\
NULL,\
}\
},\

///< public macro for finishing command without args definition
#define CLIP_DEF_COMMAND_END()\
NULL,\
},\
.args = NULL\
},\

///< public macro for defining arguments for subcommand
#define CLIP_DEF_WITH_ARGS()\
NULL,\
Expand Down
1 change: 0 additions & 1 deletion src/clip_utils_arg.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ char* clip_utils_arg_get_first(char **arg, char *cmd_line)
CLIP_CONFIG_ASSERT(arg != NULL);
CLIP_CONFIG_ASSERT(cmd_line != NULL);

int state = 0;
int escape = 0;
int quotemark = 0;
size_t arg_pos = 0;
Expand Down

0 comments on commit 7d02757

Please sign in to comment.