Ashton Fagg writes:

> Fixes the following warning:
>
> sysctl.c:835:18: warning: format specifies type 'char *' but the argument has 
> type 'void *' [-Wformat]
>                                             string, newval);
>                                                     ^~~~~~
> sysctl.c:840:18: warning: format specifies type 'char *' but the argument has 
> type 'void *' [-Wformat]
>                                             string, newval);
>
> Appears as though this was fixed in lines above these two instances, but
> these were still not properly cast.

If you're talking about other lines like L815...that was committed 22
years ago. Not really accurate to say it was "fixed" imo, but the point
stands that there's inconsistency and a clang warning.

I see no issue with this cast. newval is used extensively and cast to
various types throughout sysctl.c for better or worse.

OK?

>
> diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c
> index 5e9e562d308..a03220d7d56 100644
> --- a/sbin/sysctl/sysctl.c
> +++ b/sbin/sysctl/sysctl.c
> @@ -832,12 +832,12 @@ parse(char *string, int flags)
>                                   newval);
>                               if (len == -1) {
>                                       warnx("%s: hex string %s: invalid",
> -                                         string, newval);
> +                                         string, (char *)newval);
>                                       return;
>                               }
>                               if (len > sizeof(hex)) {
>                                       warnx("%s: hex string %s: too long",
> -                                         string, newval);
> +                                         string, (char *)newval);
>                                       return;
>                               }
>

Reply via email to