if_flags is in-kernel, so definately this should become unsigned.

But what about if_msghdr.ifm_flags? That is exposed to userland, but
I'd support moving it to unsigned because the route socket is a less
standardized interface.

struct ipoption is a little less clear. It is exposed to userland; one
example that uses this is libc/rpc/svc_tcp.c.  In that instance it is
cast to u_char as expected.  I wonder whether there is userland code which
might be affected by this, however even if there was I would support the
trend towards making this unsigned.

> the new clang complains when variables might unintentionally switch from
> a positive to a negative number.  This happens on the MULTICAST flag
> which sets the uppermost bit.
> 
> ../../../../net/if.h:#define    IFF_MULTICAST   0x8000          /* supports 
> multicast */
> 
> Thus if_flags = IFF_MULTICAST would switch from the positive 0x8000 to
> something negative.  The same happens in the ipoption struct.
> 
> What should we do?  Disable the warning or simply switch the variables
> to being unsigned?  Keep note that this diff is untested, even though I
> wouldn't expect anything bad to happen by that change...
> 
> Patrick
> 
> diff --git a/sys/net/if_var.h b/sys/net/if_var.h
> index 702fc5539c1..e254744dac8 100644
> --- a/sys/net/if_var.h
> +++ b/sys/net/if_var.h
> @@ -126,7 +126,7 @@ struct ifnet {                            /* and the 
> entries */
>  #define if_carpdev   if_carp_ptr.carp_d
>       unsigned int if_index;          /* numeric abbreviation for this if */
>       short   if_timer;               /* time 'til if_watchdog called */
> -     short   if_flags;               /* up/down, broadcast, etc. */
> +     unsigned short if_flags;        /* up/down, broadcast, etc. */
>       int     if_xflags;              /* extra softnet flags */
>       struct  if_data if_data;        /* stats and other data about if */
>       u_int32_t if_hardmtu;           /* maximum MTU device supports */
> diff --git a/sys/netinet/ip_var.h b/sys/netinet/ip_var.h
> index 7d1663dc8b3..cabb364cdc4 100644
> --- a/sys/netinet/ip_var.h
> +++ b/sys/netinet/ip_var.h
> @@ -91,7 +91,7 @@ struct      ipstat {
>  
>  struct ipoption {
>       struct  in_addr ipopt_dst;      /* first-hop dst if source routed */
> -     int8_t  ipopt_list[MAX_IPOPTLEN];       /* options proper */
> +     u_int8_t ipopt_list[MAX_IPOPTLEN]; /* options proper */
>  };
>  
>  #ifdef _KERNEL
> 

Reply via email to