On 1/29/21 9:56 AM, Parav Pandit wrote:
> @@ -1420,6 +1423,22 @@ static int port_flavour_parse(const char *flavour, 
> uint16_t *value)
>       }
>  }
>  
> +static int port_function_state_parse(const char *statestr, uint8_t *state)
> +{
> +     if (!statestr)
> +             return -EINVAL;
> +
> +     if (strcmp(statestr, "inactive") == 0) {
> +             *state = DEVLINK_PORT_FN_STATE_INACTIVE;
> +             return 0;
> +     } else if (strcmp(statestr, "active") == 0) {
> +             *state = DEVLINK_PORT_FN_STATE_ACTIVE;
> +             return 0;
> +     } else {
> +             return -EINVAL;
> +     }
> +}
> +

if another state gets added this too should be table driven - string to
type here and the inverse in the previous patch.

>  struct dl_args_metadata {
>       uint64_t o_flag;
>       char err_msg[DL_ARGS_REQUIRED_MAX_ERR_LEN];



> @@ -3897,7 +3934,6 @@ static void pr_out_port_function(struct dl *dl, struct 
> nlattr **tb_port)
>  
>               print_string(PRINT_ANY, "opstate", " opstate %s", 
> port_function_opstate(state));
>       }
> -
>       if (!dl->json_output)
>               __pr_out_indent_dec();
>       pr_out_object_end(dl);

Removing the newline intentional?




Reply via email to