How about adding inetutils u_* syntax-checks to gnulib's maint.mk?

sc_unsigned_char:
        @prohibit=u''_char \
        halt='don'\''t use u''_char; instead use unsigned char' \
          $(_sc_search_regexp)

sc_unsigned_long:
        @prohibit=u''_long \
        halt='don'\''t use u''_long; instead use unsigned long' \
          $(_sc_search_regexp)

sc_unsigned_short:
        @prohibit=u''_short \
        halt='don'\''t use u''_short; instead use unsigned short' \
          $(_sc_search_regexp)

sc_unsigned_int:
        @prohibit=u''_int \
        halt='don'\''t use u''_int; instead use unsigned int' \
          $(_sc_search_regexp)


The u_char/u_long/u_short/u_int idiom used to be common but today I
don't think any reasonable code should use it.  Does anyone have more
background or opinions on this?

Glibc definitions:

/usr/include/features.h:
   __USE_MISC           Define things from 4.3BSD or System V Unix.
/usr/include/x86_64-linux-gnu/sys/types.h:
#ifdef  __USE_MISC
# ifndef __u_char_defined
typedef __u_char u_char;
typedef __u_short u_short;
typedef __u_int u_int;
typedef __u_long u_long;
typedef __quad_t quad_t;
typedef __u_quad_t u_quad_t;
typedef __fsid_t fsid_t;
#  define __u_char_defined
# endif
typedef __loff_t loff_t;
#endif
/usr/include/x86_64-linux-gnu/bits/types.h:
/* Convenience types.  */
typedef unsigned char __u_char;
typedef unsigned short int __u_short;
typedef unsigned int __u_int;
typedef unsigned long int __u_long;

The only usage in gnulib is lib/inet_ntop.c and lib/inet_pton.c.  It
seems u_char was removed in most places of the code except a few
remaining type casts/comments:

lib/inet_ntop.c: *      (2) takes a u_char* not an in_addr as input
lib/inet_pton.c:          *tp++ = (u_char) (val >> 8) & 0xff;
lib/inet_pton.c:          *tp++ = (u_char) val & 0xff;
lib/inet_pton.c:      *tp++ = (u_char) (val >> 8) & 0xff;
lib/inet_pton.c:      *tp++ = (u_char) val & 0xff;

/Simon

Attachment: signature.asc
Description: PGP signature

Reply via email to