On Thu, 2019-09-19 at 16:00 +0200, Andrew Lunn wrote:
> [External]
> 
> > -static int parse_named_u8(struct cmd_context *ctx, const char *name,
> > u8 *val)
> > +static int parse_named_uint(struct cmd_context *ctx, const char *name,
> > +                       void *val, enum tunable_type_id type_id)
> >  {
> >     if (ctx->argc < 2)
> >             return 0;
> > @@ -5026,7 +5051,16 @@ static int parse_named_u8(struct cmd_context
> > *ctx, const char *name, u8 *val)
> >     if (strcmp(*ctx->argp, name))
> >             return 0;
> >  
> > -   *val = get_uint_range(*(ctx->argp + 1), 0, 0xff);
> > +   switch (type_id) {
> > +   case ETHTOOL_TUNABLE_U8:
> > +           *(u8 *)val = get_uint_range(*(ctx->argp + 1), 0, 0xff);
> > +           break;
> > +   case ETHTOOL_TUNABLE_U16:
> > +           *(u16 *)val = get_uint_range(*(ctx->argp + 1), 0, 0xffff);
> 
> I personally don't like these casts. Could you refactor this code in
> some other way to avoid them. Make the parse_named_u8()
> parse_named_u16() a bit fatter, and the shared code a bit slimmer?
> 

Sure thing.
V2 coming shortly.

> Thanks
>       Andrew

Reply via email to