]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Use more the EXTRACT_U_1() macro (47/n)
authorFrancois-Xavier Le Bail <[email protected]>
Mon, 4 Dec 2017 21:45:01 +0000 (22:45 +0100)
committerFrancois-Xavier Le Bail <[email protected]>
Tue, 5 Dec 2017 09:45:44 +0000 (10:45 +0100)
In: if (... *(p) ...) ...

14 files changed:
print-ahcp.c
print-arp.c
print-ascii.c
print-atm.c
print-llc.c
print-msdp.c
print-radius.c
print-resp.c
print-rpki-rtr.c
print-sl.c
print-snmp.c
print-telnet.c
print-tftp.c
smbutil.c

index 0600290316c2f20211f0dd62764fc0e78d986601..8dfe9d1611d81b69a2601902d725523fdb5cc0c8 100644 (file)
@@ -355,7 +355,7 @@ ahcp_print(netdissect_options *ndo, const u_char *cp, const u_int len)
                goto invalid;
        /* Magic */
        ND_TCHECK_1(cp);
-       if (*cp != AHCP_MAGIC_NUMBER)
+       if (EXTRACT_U_1(cp) != AHCP_MAGIC_NUMBER)
                goto invalid;
        cp += 1;
        /* Version */
index 7c57870a20b38f48c245d20ffa60d460a6e7365b..dc8bf23f3ea384091935e04629e17dae7e59cc53 100644 (file)
@@ -181,7 +181,7 @@ static int
 isnonzero(const u_char *a, size_t len)
 {
        while (len > 0) {
-               if (*a != 0)
+               if (EXTRACT_U_1(a) != 0)
                        return (1);
                a++;
                len--;
index 4ef38a17a50dba22e246d1f3a712665e0864fa4c..151e5c2867a1b7f50892552c1911e38d5b4bb94e 100644 (file)
@@ -46,6 +46,7 @@
 #include <stdio.h>
 
 #include "netdissect.h"
+#include "extract.h"
 
 #define ASCII_LINELENGTH 300
 #define HEXDUMP_BYTES_PER_LINE 16
@@ -78,7 +79,7 @@ ascii_print(netdissect_options *ndo,
                         *
                         * In the middle of a line, just print a '.'.
                         */
-                       if (length > 1 && *cp != '\n')
+                       if (length > 1 && EXTRACT_U_1(cp) != '\n')
                                ND_PRINT((ndo, "."));
                } else {
                        if (!ND_ISGRAPH(s) &&
index 27106b4645983e37f91e58776b696732bef54cad..ed29c6d5ad215e297b39e12b64c21e6a27894a29 100644 (file)
@@ -259,7 +259,7 @@ atm_if_print(netdissect_options *ndo,
        }
 
         /* Cisco Style NLPID ? */
-        if (*p == LLC_UI) {
+        if (EXTRACT_U_1(p) == LLC_UI) {
             if (ndo->ndo_eflag)
                 ND_PRINT((ndo, "CNLPID "));
             isoclns_print(ndo, p + 1, length - 1);
index 3673ef8d0c5b15c551fb86676d98353f403960db..d73ac847dedfa2dbf1387a0ab0e518c9a873db8a 100644 (file)
@@ -372,7 +372,7 @@ llc_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen,
                                        ND_DEFAULTPRINT((const u_char *)p, caplen);
                                return (hdrlen);
                        }
-                       if (*p == LLC_XID_FI) {
+                       if (EXTRACT_U_1(p) == LLC_XID_FI) {
                                if (caplen < 3 || length < 3) {
                                        ND_PRINT((ndo, "[|llc]"));
                                        if (caplen > 0)
index e2ffde1b23f2f54ec872196f0613eb51f27ee0ff..df59b46394ae3fc491dca500e695937ea23c19ec 100644 (file)
@@ -61,7 +61,7 @@ msdp_print(netdissect_options *ndo, const u_char *sp, u_int length)
                                ND_PRINT((ndo, " SA-Response"));
                        ND_TCHECK_1(sp);
                        ND_PRINT((ndo, " %u entries", EXTRACT_U_1(sp)));
-                       if ((u_int)((*sp * 12) + 8) < len) {
+                       if ((u_int)((EXTRACT_U_1(sp) * 12) + 8) < len) {
                                ND_PRINT((ndo, " [w/data]"));
                                if (ndo->ndo_vflag > 1) {
                                        ND_PRINT((ndo, " "));
index 5ce68d163cd8bff63cb80dd3c14e6754f73de602..cb170170da3d13366659362cd420c83c2249cb14 100644 (file)
@@ -609,7 +609,7 @@ print_attr_string(netdissect_options *ndo,
       case TUNNEL_ASSIGN_ID:
       case TUNNEL_CLIENT_AUTH:
       case TUNNEL_SERVER_AUTH:
-           if (*data <= 0x1F)
+           if (EXTRACT_U_1(data) <= 0x1F)
            {
               if (length < 1)
                  goto trunc;
index c2b6e63a7409bd0b3052c6bd73f1578506060519..71b198fd5cead9e871eac77ee5baccee33ce9cfb 100644 (file)
@@ -467,7 +467,7 @@ resp_get_length(netdissect_options *ndo, register const u_char *bp, int len, con
     ND_TCHECK_1(bp);
     too_large = 0;
     neg = 0;
-    if (*bp == '-') {
+    if (EXTRACT_U_1(bp) == '-') {
         neg = 1;
         bp++;
         len--;
@@ -508,7 +508,7 @@ resp_get_length(netdissect_options *ndo, register const u_char *bp, int len, con
      * OK, we found a non-digit character.  It should be a \r, followed
      * by a \n.
      */
-    if (*bp != '\r') {
+    if (EXTRACT_U_1(bp) != '\r') {
         bp++;
         goto invalid;
     }
@@ -517,7 +517,7 @@ resp_get_length(netdissect_options *ndo, register const u_char *bp, int len, con
     if (len == 0)
         goto trunc;
     ND_TCHECK_1(bp);
-    if (*bp != '\n') {
+    if (EXTRACT_U_1(bp) != '\n') {
         bp++;
         goto invalid;
     }
index 1af8e863794a53fce7798f5295f9693926d9f67e..4e2e7c1461b79ca2223ea56138e734d06c7f5c89 100644 (file)
@@ -183,7 +183,7 @@ rpki_rtr_pdu_print (netdissect_options *ndo, const u_char *tptr, const u_int len
 
     /* Protocol Version */
     ND_TCHECK_1(tptr);
-    if (*tptr != 0) {
+    if (EXTRACT_U_1(tptr) != 0) {
        /* Skip the rest of the input buffer because even if this is
         * a well-formed PDU of a future RPKI-Router protocol version
         * followed by a well-formed PDU of RPKI-Router protocol
index 7d2068ff7db55099cd2aaf1405e52d13f4600957..5567007a24d2dfb94746df1156ba44375dc80215 100644 (file)
@@ -198,7 +198,8 @@ print_sl_change(netdissect_options *ndo,
 {
        register u_int i;
 
-       if ((i = *cp++) == 0) {
+       if ((i = EXTRACT_U_1(cp)) == 0) {
+               cp++;
                i = EXTRACT_BE_U_2(cp);
                cp += 2;
        }
@@ -212,7 +213,8 @@ print_sl_winchange(netdissect_options *ndo,
 {
        register short i;
 
-       if ((i = *cp++) == 0) {
+       if ((i = EXTRACT_U_1(cp)) == 0) {
+               cp++;
                i = EXTRACT_BE_U_2(cp);
                cp += 2;
        }
index 0c90132b5d2d74e5fd9326987ea86af4336e449e..e7b64aee56466434821e0eb5ea7a3fa51422fa43 100644 (file)
@@ -543,7 +543,7 @@ asn1_parse(netdissect_options *ndo,
                                        ND_PRINT((ndo, "[asnlen=0]"));
                                        return -1;
                                }
-                               if (*p & ASN_BIT8)      /* negative */
+                               if (EXTRACT_U_1(p) & ASN_BIT8)  /* negative */
                                        data = -1;
                                for (i = elem->asnlen; i-- > 0; p++)
                                        data = (data << ASN_SHIFT8) | EXTRACT_U_1(p);
@@ -772,7 +772,7 @@ asn1_print(netdissect_options *ndo,
                for (; i-- > 0; p++) {
                        ND_TCHECK_1(p);
                        o = (o << ASN_SHIFT7) + (*p & ~ASN_BIT8);
-                       if (*p & ASN_LONGLEN)
+                       if (EXTRACT_U_1(p) & ASN_LONGLEN)
                                continue;
 
                        /*
@@ -924,7 +924,7 @@ smi_decode_oid(netdissect_options *ndo,
        for (*oidlen = 0; i-- > 0; p++) {
                ND_TCHECK_1(p);
                o = (o << ASN_SHIFT7) + (*p & ~ASN_BIT8);
-               if (*p & ASN_LONGLEN)
+               if (EXTRACT_U_1(p) & ASN_LONGLEN)
                    continue;
 
                /*
index bbc4f231608fcb57a80b5bc550cea46d6882d02d..41e24462e199caa9ed1a1be0015e595caff1b2ca 100644 (file)
@@ -444,7 +444,7 @@ telnet_parse(netdissect_options *ndo, const u_char *sp, u_int length, int print)
                        p++;
                }
                ND_TCHECK_1(p);
-               if (*p != IAC)
+               if (EXTRACT_U_1(p) != IAC)
                        goto pktend;
 
                switch (x) {
index c0b1338493c7533642380e7f6e4322253ede5bc4..5ebf93335cee0796e059056b9252ddc026a527ff 100644 (file)
@@ -140,7 +140,7 @@ tftp_print(netdissect_options *ndo,
                /* Print options, if any */
                while (length != 0) {
                        ND_TCHECK_1(bp);
-                       if (*bp != '\0')
+                       if (EXTRACT_U_1(bp) != '\0')
                                ND_PRINT((ndo, " "));
                        ui = fn_printztn(ndo, bp, length, ndo->ndo_snapend);
                        if (ui == 0)
@@ -154,7 +154,7 @@ tftp_print(netdissect_options *ndo,
                /* Print options */
                while (length != 0) {
                        ND_TCHECK_1(bp);
-                       if (*bp != '\0')
+                       if (EXTRACT_U_1(bp) != '\0')
                                ND_PRINT((ndo, " "));
                        ui = fn_printztn(ndo, bp, length, ndo->ndo_snapend);
                        if (ui == 0)
index 3206ead1bd36b7e244e32eb6e888f6c75d2924c3..47f798a4e88c194b1c37d8e859d80141fb2c0d1c 100644 (file)
--- a/smbutil.c
+++ b/smbutil.c
@@ -637,7 +637,7 @@ smb_fdata1(netdissect_options *ndo,
            uint32_t len;
 
            ND_TCHECK_1(buf);
-           if (*buf != 4 && *buf != 2) {
+           if (EXTRACT_U_1(buf) != 4 && EXTRACT_U_1(buf) != 2) {
                ND_PRINT((ndo, "Error! ASCIIZ buffer of type %u", EXTRACT_U_1(buf)));
                return maxbuf;  /* give up */
            }