]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Remove unnecessary float and double variables.
authorGuy Harris <[email protected]>
Wed, 27 Mar 2024 07:01:03 +0000 (00:01 -0700)
committerGuy Harris <[email protected]>
Wed, 27 Mar 2024 07:02:21 +0000 (00:02 -0700)
GET_BE_F_4() and GET_BE_F_8() return floating-point variables, so we can
directly call them in an ND_PRINT() call; there's no need to store the
value in a variable and use that.

print-bgp.c
print-isoclns.c
print-lmp.c
print-ospf.c
print-rsvp.c

index 8f319f85dca8a1b3dd18a1de870f29d1800dece2..5fbaae0160675c6f8419c46488ec4f01fa7a9a9d 100644 (file)
@@ -893,7 +893,6 @@ static void
 bgp_extended_community_print(netdissect_options *ndo,
                              const u_char *pptr)
 {
-    float bw;
     /* allocate space for the largest possible string */
     char astostr[AS_STR_SIZE];
 
@@ -925,9 +924,8 @@ bgp_extended_community_print(netdissect_options *ndo,
             break;
 
     case BGP_EXT_COM_LINKBAND:
-            bw = GET_BE_F_4(pptr + 4);
             ND_PRINT("bandwidth: %.3f Mbps",
-                     bw*8/1000000);
+                     GET_BE_F_4(pptr + 4)*8/1000000);
             break;
 
     case BGP_EXT_COM_OVS:
index 3ac10c0d0c3e5bd7f1efda711d9c983e866d1f6c..d41cf41da4a2cb6e584451ae4110eec52166a2bd 100644 (file)
@@ -1950,7 +1950,6 @@ isis_print_ext_is_reach(netdissect_options *ndo,
     u_int subtlv_type,subtlv_len,subtlv_sum_len;
     int proc_bytes = 0; /* how many bytes did we process ? */
     u_int te_class,priority_level,gmpls_switch_cap;
-    float bw;
 
     ND_TCHECK_LEN(tptr, NODE_ID_LEN);
     if (tlv_remaining < NODE_ID_LEN)
@@ -2037,19 +2036,16 @@ isis_print_ext_is_reach(netdissect_options *ndo,
                 break;
             case ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW :
             case ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW:
-                if (subtlv_len >= 4) {
-                    bw = GET_BE_F_4(tptr);
-                    ND_PRINT(", %.3f Mbps", bw * 8 / 1000000);
-                }
+                if (subtlv_len >= 4)
+                    ND_PRINT(", %.3f Mbps", GET_BE_F_4(tptr) * 8 / 1000000);
                 break;
             case ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW :
                 if (subtlv_len >= 32) {
                     for (te_class = 0; te_class < 8; te_class++) {
-                        bw = GET_BE_F_4(tptr);
                         ND_PRINT("%s  TE-Class %u: %.3f Mbps",
                                   indent,
                                   te_class,
-                                  bw * 8 / 1000000);
+                                  GET_BE_F_4(tptr) * 8 / 1000000);
                         tptr += 4;
                         subtlv_len -= 4;
                         subtlv_sum_len -= 4;
@@ -2073,11 +2069,10 @@ isis_print_ext_is_reach(netdissect_options *ndo,
                 for (te_class = 0; subtlv_len != 0; te_class++) {
                     if (subtlv_len < 4)
                         break;
-                    bw = GET_BE_F_4(tptr);
                     ND_PRINT("%s  Bandwidth constraint CT%u: %.3f Mbps",
                               indent,
                               te_class,
-                              bw * 8 / 1000000);
+                              GET_BE_F_4(tptr) * 8 / 1000000);
                     tptr += 4;
                     subtlv_len -= 4;
                     subtlv_sum_len -= 4;
@@ -2133,11 +2128,10 @@ isis_print_ext_is_reach(netdissect_options *ndo,
                     proc_bytes += 4;
                     ND_PRINT("%s  Max LSP Bandwidth:", indent);
                     for (priority_level = 0; priority_level < 8; priority_level++) {
-                        bw = GET_BE_F_4(tptr);
                         ND_PRINT("%s    priority level %u: %.3f Mbps",
                                   indent,
                                   priority_level,
-                                  bw * 8 / 1000000);
+                                  GET_BE_F_4(tptr) * 8 / 1000000);
                         tptr += 4;
                         subtlv_len -= 4;
                         subtlv_sum_len -= 4;
@@ -2150,16 +2144,17 @@ isis_print_ext_is_reach(netdissect_options *ndo,
                     case GMPLS_PSC4:
                         if (subtlv_len < 6)
                             break;
-                        bw = GET_BE_F_4(tptr);
-                        ND_PRINT("%s  Min LSP Bandwidth: %.3f Mbps", indent, bw * 8 / 1000000);
+                        ND_PRINT("%s  Min LSP Bandwidth: %.3f Mbps",
+                                 indent,
+                                 GET_BE_F_4(tptr) * 8 / 1000000);
                         ND_PRINT("%s  Interface MTU: %u", indent,
                                  GET_BE_U_2(tptr + 4));
                         break;
                     case GMPLS_TSC:
                         if (subtlv_len < 8)
                             break;
-                        bw = GET_BE_F_4(tptr);
-                        ND_PRINT("%s  Min LSP Bandwidth: %.3f Mbps", indent, bw * 8 / 1000000);
+                        ND_PRINT("%s  Min LSP Bandwidth: %.3f Mbps", indent,
+                                  GET_BE_F_4(tptr) * 8 / 1000000);
                         ND_PRINT("%s  Indication %s", indent,
                                   tok2str(gmpls_switch_cap_tsc_indication_values, "Unknown (%u)", GET_U_1((tptr + 4))));
                         break;
index 3b9bb0f20db28a6594277c6bebd4b811369fb42f..e02dc460cd18ae64adafde165c90f4f4e9631657 100644 (file)
@@ -362,7 +362,6 @@ lmp_print_data_link_subobjs(netdissect_options *ndo, const u_char *obj_tptr,
 {
     int hexdump = FALSE;
     int subobj_type, subobj_len;
-    float bw;
 
     while (total_subobj_len > 0 && hexdump == FALSE ) {
        subobj_type = GET_U_1(obj_tptr + offset);
@@ -397,12 +396,10 @@ lmp_print_data_link_subobjs(netdissect_options *ndo, const u_char *obj_tptr,
                        "Unknown",
                        GET_U_1(obj_tptr + offset + 3)),
                GET_U_1(obj_tptr + offset + 3));
-           bw = GET_BE_F_4(obj_tptr + offset + 4);
            ND_PRINT("\n\t      Min Reservable Bandwidth: %.3f Mbps",
-                bw*8/1000000);
-           bw = GET_BE_F_4(obj_tptr + offset + 8);
+               GET_BE_F_4(obj_tptr + offset + 4)*8/1000000);
            ND_PRINT("\n\t      Max Reservable Bandwidth: %.3f Mbps",
-                bw*8/1000000);
+               GET_BE_F_4(obj_tptr + offset + 8)*8/1000000);
            break;
        case WAVELENGTH_SUBOBJ:
            ND_PRINT("\n\t      Wavelength: %u",
@@ -429,7 +426,6 @@ lmp_print(netdissect_options *ndo,
     int hexdump;
     u_int offset;
     u_int link_type;
-    float bw;
 
     ndo->ndo_protocol = "lmp";
     tptr=pptr;
@@ -795,8 +791,8 @@ lmp_print(netdissect_options *ndo,
                        GET_BE_U_2(obj_tptr + 10),
                        GET_BE_U_2(obj_tptr + 10),
                        GET_BE_U_2(obj_tptr + 10)&8000 ? " (Payload test messages capable)" : "");
-                bw = GET_BE_F_4(obj_tptr + 12);
-               ND_PRINT("\n\t    Transmission Rate: %.3f Mbps",bw*8/1000000);
+               ND_PRINT("\n\t    Transmission Rate: %.3f Mbps",
+                       GET_BE_F_4(obj_tptr + 12)*8/1000000);
                ND_PRINT("\n\t    Wavelength: %u",
                        GET_BE_U_4(obj_tptr + 16));
                break;
index fe06d21bf6513006d4dff7f677fc1a5b56c7998f..9bdc85841a8ebf6fef53661b1e9cd973d677013e 100644 (file)
@@ -327,7 +327,6 @@ ospf_te_tlv_link_print(netdissect_options *ndo,
 {
     u_int subtlv_type, subtlv_length;
     u_int priority_level, te_class, count_srlg;
-    float bw;
 
     while (tlv_length != 0) {
         if (tlv_length < 4) {
@@ -391,8 +390,7 @@ ospf_te_tlv_link_print(netdissect_options *ndo,
                 ND_PRINT(" != 4");
                 goto invalid;
             }
-            bw = GET_BE_F_4(tptr);
-            ND_PRINT(", %.3f Mbps", bw * 8 / 1000000);
+            ND_PRINT(", %.3f Mbps", GET_BE_F_4(tptr) * 8 / 1000000);
             break;
         case LS_OPAQUE_TE_LINK_SUBTLV_UNRES_BW:
             if (subtlv_length != 32) {
@@ -400,10 +398,9 @@ ospf_te_tlv_link_print(netdissect_options *ndo,
                 goto invalid;
             }
             for (te_class = 0; te_class < 8; te_class++) {
-                bw = GET_BE_F_4(tptr + te_class * 4);
                 ND_PRINT("\n\t\tTE-Class %u: %.3f Mbps",
                        te_class,
-                       bw * 8 / 1000000);
+                       GET_BE_F_4(tptr + te_class * 4) * 8 / 1000000);
             }
             break;
         case LS_OPAQUE_TE_LINK_SUBTLV_BW_CONSTRAINTS:
@@ -425,10 +422,9 @@ ospf_te_tlv_link_print(netdissect_options *ndo,
             }
             /* decode BCs until the subTLV ends */
             for (te_class = 0; te_class < (subtlv_length-4)/4; te_class++) {
-                bw = GET_BE_F_4(tptr + 4 + te_class * 4);
                 ND_PRINT("\n\t\t  Bandwidth constraint CT%u: %.3f Mbps",
                        te_class,
-                       bw * 8 / 1000000);
+                       GET_BE_F_4(tptr + 4 + te_class * 4) * 8 / 1000000);
             }
             break;
         case LS_OPAQUE_TE_LINK_SUBTLV_TE_METRIC:
@@ -458,10 +454,9 @@ ospf_te_tlv_link_print(netdissect_options *ndo,
             ND_PRINT("\n\t\tLSP Encoding: %s\n\t\tMax LSP Bandwidth:",
                    tok2str(gmpls_encoding_values, "Unknown", GET_U_1((tptr + 1))));
             for (priority_level = 0; priority_level < 8; priority_level++) {
-                bw = GET_BE_F_4(tptr + 4 + (priority_level * 4));
                 ND_PRINT("\n\t\t  priority level %u: %.3f Mbps",
                        priority_level,
-                       bw * 8 / 1000000);
+                       GET_BE_F_4(tptr + 4 + (priority_level * 4)) * 8 / 1000000);
             }
             break;
         case LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE:
index 2ff9fa96a94bc722fbd242267fa966f45970e2b2..ce29e42dc6f216057ee10af51950c5083c374451 100644 (file)
@@ -514,7 +514,6 @@ rsvp_intserv_print(netdissect_options *ndo,
                    const u_char *tptr, u_int obj_tlen)
 {
     u_int parameter_id,parameter_length;
-    float bw;
 
     ND_ICHECK_U(obj_tlen, <, 4);
     parameter_id = GET_U_1(tptr);
@@ -551,8 +550,8 @@ rsvp_intserv_print(netdissect_options *ndo,
         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
         */
         if (parameter_length == 4) {
-            bw = GET_BE_F_4(tptr + 4);
-            ND_PRINT("\n\t\tPath b/w estimate: %.10g Mbps", bw / 125000);
+            ND_PRINT("\n\t\tPath b/w estimate: %.10g Mbps",
+                     GET_BE_F_4(tptr + 4) / 125000);
         }
         break;
 
@@ -604,12 +603,12 @@ rsvp_intserv_print(netdissect_options *ndo,
         */
 
         if (parameter_length == 20) {
-            bw = GET_BE_F_4(tptr + 4);
-            ND_PRINT("\n\t\tToken Bucket Rate: %.10g Mbps", bw / 125000);
-            bw = GET_BE_F_4(tptr + 8);
-            ND_PRINT("\n\t\tToken Bucket Size: %.10g bytes", bw);
-            bw = GET_BE_F_4(tptr + 12);
-            ND_PRINT("\n\t\tPeak Data Rate: %.10g Mbps", bw / 125000);
+            ND_PRINT("\n\t\tToken Bucket Rate: %.10g Mbps",
+                     GET_BE_F_4(tptr + 4) / 125000);
+            ND_PRINT("\n\t\tToken Bucket Size: %.10g bytes",
+                     GET_BE_F_4(tptr + 8));
+            ND_PRINT("\n\t\tPeak Data Rate: %.10g Mbps",
+                     GET_BE_F_4(tptr + 12) / 125000);
             ND_PRINT("\n\t\tMinimum Policed Unit: %u bytes",
                      GET_BE_U_4(tptr + 16));
             ND_PRINT("\n\t\tMaximum Packet Size: %u bytes",
@@ -629,8 +628,7 @@ rsvp_intserv_print(netdissect_options *ndo,
         */
 
         if (parameter_length == 8) {
-            bw = GET_BE_F_4(tptr + 4);
-            ND_PRINT("\n\t\tRate: %.10g Mbps", bw / 125000);
+            ND_PRINT("\n\t\tRate: %.10g Mbps", GET_BE_F_4(tptr + 4) / 125000);
             ND_PRINT("\n\t\tSlack Term: %u", GET_BE_U_4(tptr + 8));
         }
         break;
@@ -684,7 +682,6 @@ rsvp_obj_print(netdissect_options *ndo,
     u_int obj_tlen,intserv_serv_tlen;
     int hexdump;
     u_int processed,padbytes,error_code,error_value,i,sigcheck;
-    float bw;
     u_int namelen;
 
     u_int action, subchannel;
@@ -1541,13 +1538,12 @@ rsvp_obj_print(netdissect_options *ndo,
             case RSVP_CTYPE_1: /* new style */
                 if (obj_tlen < sizeof(struct rsvp_obj_frr_t))
                     goto obj_tooshort;
-                bw = GET_BE_F_4(obj_ptr.rsvp_obj_frr->bandwidth);
                 ND_PRINT("%s  Setup Priority: %u, Holding Priority: %u, Hop-limit: %u, Bandwidth: %.10g Mbps",
                        indent,
                        GET_U_1(obj_ptr.rsvp_obj_frr->setup_prio),
                        GET_U_1(obj_ptr.rsvp_obj_frr->hold_prio),
                        GET_U_1(obj_ptr.rsvp_obj_frr->hop_limit),
-                       bw * 8 / 1000000);
+                       GET_BE_F_4(obj_ptr.rsvp_obj_frr->bandwidth) * 8 / 1000000);
                 ND_PRINT("%s  Include-any: 0x%08x, Exclude-any: 0x%08x, Include-all: 0x%08x",
                        indent,
                        GET_BE_U_4(obj_ptr.rsvp_obj_frr->include_any),
@@ -1560,13 +1556,12 @@ rsvp_obj_print(netdissect_options *ndo,
             case RSVP_CTYPE_TUNNEL_IPV4: /* old style */
                 if (obj_tlen < 16)
                     goto obj_tooshort;
-                bw = GET_BE_F_4(obj_ptr.rsvp_obj_frr->bandwidth);
                 ND_PRINT("%s  Setup Priority: %u, Holding Priority: %u, Hop-limit: %u, Bandwidth: %.10g Mbps",
                        indent,
                        GET_U_1(obj_ptr.rsvp_obj_frr->setup_prio),
                        GET_U_1(obj_ptr.rsvp_obj_frr->hold_prio),
                        GET_U_1(obj_ptr.rsvp_obj_frr->hop_limit),
-                       bw * 8 / 1000000);
+                       GET_BE_F_4(obj_ptr.rsvp_obj_frr->bandwidth) * 8 / 1000000);
                 ND_PRINT("%s  Include Colors: 0x%08x, Exclude Colors: 0x%08x",
                        indent,
                        GET_BE_U_4(obj_ptr.rsvp_obj_frr->include_any),