]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Clean up To DS and From DS checks.
authorGuy Harris <[email protected]>
Mon, 27 Apr 2015 07:02:31 +0000 (00:02 -0700)
committerGuy Harris <[email protected]>
Mon, 27 Apr 2015 07:02:31 +0000 (00:02 -0700)
Rewrite get_data_src_dst_mac() to test To DS and From DS only once; that
also more clearly means that there's no way to escape from that function
without setting both pointers, so the compiler doesn't think there's a
way to do so.

print-802_11.c

index 2b4688deadac262aaf49aaff7f7bbda863bc1949..0fffcb5cc0c4996b83794e144f464fa8ba89686e 100644 (file)
@@ -2068,18 +2068,26 @@ get_data_src_dst_mac(uint16_t fc, const u_char *p, const uint8_t **srcp,
 #define ADDR3  (p + 16)
 #define ADDR4  (p + 24)
 
-       if (!FC_TO_DS(fc) && !FC_FROM_DS(fc)) {
-               *srcp = ADDR2;
-               *dstp = ADDR1;
-       } else if (!FC_TO_DS(fc) && FC_FROM_DS(fc)) {
-               *srcp = ADDR3;
-               *dstp = ADDR1;
-       } else if (FC_TO_DS(fc) && !FC_FROM_DS(fc)) {
-               *srcp = ADDR2;
-               *dstp = ADDR3;
-       } else if (FC_TO_DS(fc) && FC_FROM_DS(fc)) {
-               *srcp = ADDR4;
-               *dstp = ADDR3;
+       if (!FC_TO_DS(fc)) {
+               if (!FC_FROM_DS(fc)) {
+                       /* not To DS and not From DS */
+                       *srcp = ADDR2;
+                       *dstp = ADDR1;
+               } else {
+                       /* not To DS and From DS */
+                       *srcp = ADDR3;
+                       *dstp = ADDR1;
+               }
+       } else {
+               if (!FC_FROM_DS(fc)) {
+                       /* From DS and not To DS */
+                       *srcp = ADDR2;
+                       *dstp = ADDR3;
+               } else {
+                       /* To DS and From DS */
+                       *srcp = ADDR4;
+                       *dstp = ADDR3;
+               }
        }
 
 #undef ADDR1