[LTP] [PATCH v4 3/3] tst_run_shell.c: Add new function handle new needs_cmds
    Petr Vorel 
    pvorel@suse.cz
       
    Fri Oct 17 17:30:46 CEST 2025
    
    
  
Hi Wei,
> +	UJSON_ARR_FOREACH(reader, val) {
> +		UJSON_OBJ_FOREACH_FILTER(reader, val, &cmd_obj, ujson_empty_obj) {
> +			switch ((enum cmd_ids)val->idx) {
> +			case CMD:
> +				ret[i].cmd = strdup(val->val_str);
> +			break;
> +			case OPTIONAL:
> +				ret[i].optional = val->val_int;
> +			break;
> +			case MKFS_VER:
> +				ret[i].present = val->val_int;
My compiler shows 2 warnings:
tst_run_shell.c:302:25: warning: case value ‘3’ not in enumerated type ‘enum cmd_ids’ [-Wswitch]
  302 |                         case MKFS_VER:
      |                         ^~~~
=> Indeed, MKFS_VER is part of enum fs_ids, it should not be here.
Another warning:
tst_run_shell.c: In function ‘parse_cmds’:
tst_run_shell.c:295:25: warning: enumeration value ‘PRESENT’ not handled in switch [-Wswitch]
  295 |                         switch ((enum cmd_ids)val->idx) {
      |                         ^~~~~~
=> Either it MKFS_VER should have PRESENT, or, because struct tst_cmd->present
should not be set in the test, but by C API, we might want to call ujson_err()?
Kind regards,
Petr
    
    
More information about the ltp
mailing list