]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Declare bitfields as "u_int", not "u_char"; ANSI C doesn't guarantee
authorguy <guy>
Fri, 29 Sep 2000 05:05:47 +0000 (05:05 +0000)
committerguy <guy>
Fri, 29 Sep 2000 05:05:47 +0000 (05:05 +0000)
that bitfields other than "int" or "unsigned int" are allowed, some
compilers warn about them, and, given that the declaration of a bit
field says how many bits it is wide, declaring them "u_char" doesn't
have any advantage (other than making it a bit clearer, when reading the
header, that the bitfields in question are part of a single byte).

ip.h
tcp.h

diff --git a/ip.h b/ip.h
index 028e9670d7b462eee9242950c6de9ecb06ec30c0..9be7544a4c3631bd165a0a48fe8fb95663231ed1 100644 (file)
--- a/ip.h
+++ b/ip.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/ip.h,v 1.3 2000-09-29 04:58:33 guy Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/ip.h,v 1.4 2000-09-29 05:05:47 guy Exp $ (LBL) */
 /*
  * Copyright (c) 1982, 1986, 1993
  *     The Regents of the University of California.  All rights reserved.
  */
 struct ip {
 #if BYTE_ORDER == LITTLE_ENDIAN 
-       u_char  ip_hl:4,                /* header length */
+       u_int   ip_hl:4,                /* header length */
                ip_v:4;                 /* version */
 #endif
 #if BYTE_ORDER == BIG_ENDIAN 
-       u_char  ip_v:4,                 /* version */
+       u_int   ip_v:4,                 /* version */
                ip_hl:4;                /* header length */
 #endif
        u_char  ip_tos;                 /* type of service */
@@ -151,11 +151,11 @@ struct    ip_timestamp {
        u_char  ipt_len;                /* size of structure (variable) */
        u_char  ipt_ptr;                /* index of current entry */
 #if BYTE_ORDER == LITTLE_ENDIAN 
-       u_char  ipt_flg:4,              /* flags, see below */
+       u_int   ipt_flg:4,              /* flags, see below */
                ipt_oflw:4;             /* overflow counter */
 #endif
 #if BYTE_ORDER == BIG_ENDIAN 
-       u_char  ipt_oflw:4,             /* overflow counter */
+       u_int   ipt_oflw:4,             /* overflow counter */
                ipt_flg:4;              /* flags, see below */
 #endif
        union ipt_timestamp {
diff --git a/tcp.h b/tcp.h
index 0addc8a4d439f9e710c0825d8735a481a4586461..c39cce7ea390cce5b7c81e53b8175b01a9767d2e 100644 (file)
--- a/tcp.h
+++ b/tcp.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/tcp.h,v 1.2 2000-09-23 08:54:43 guy Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/tcp.h,v 1.3 2000-09-29 05:05:48 guy Exp $ (LBL) */
 /*
  * Copyright (c) 1982, 1986, 1993
  *     The Regents of the University of California.  All rights reserved.
@@ -68,11 +68,11 @@ struct tcphdr {
        tcp_seq th_seq;                 /* sequence number */
        tcp_seq th_ack;                 /* acknowledgement number */
 #if BYTE_ORDER == LITTLE_ENDIAN 
-       u_char  th_x2:4,                /* (unused) */
+       u_int   th_x2:4,                /* (unused) */
                th_off:4;               /* data offset */
 #endif
 #if BYTE_ORDER == BIG_ENDIAN 
-       u_char  th_off:4,               /* data offset */
+       u_int   th_off:4,               /* data offset */
                th_x2:4;                /* (unused) */
 #endif
        u_char  th_flags;