Parcourir la source

[master] fix clang static analyzer issue

Value stored to 'opt_len' during its initialization is never read

discussed via jabber

also use const
JINMEI Tatuya il y a 12 ans
Parent
commit
ddd815eb74
1 fichiers modifiés avec 4 ajouts et 6 suppressions
  1. 4 6
      tests/tools/perfdhcp/pkt_transform.cc

+ 4 - 6
tests/tools/perfdhcp/pkt_transform.cc

@@ -196,12 +196,10 @@ PktTransform::unpackOptions(const OptionBuffer& in_buffer,
 
         // Get option length which is supposed to be after option type.
         offset += offset_step;
-        uint16_t opt_len = in_buffer[offset] * 256 + in_buffer[offset + 1];
-        if (option->getUniverse() == Option::V6) {
-            opt_len = in_buffer[offset] * 256 + in_buffer[offset + 1];
-        } else {
-            opt_len = in_buffer[offset];
-        }
+        const uint16_t opt_len =
+            (option->getUniverse() == Option::V6) ?
+            in_buffer[offset] * 256 + in_buffer[offset + 1] :
+            in_buffer[offset];
 
         // Check if packet is not truncated.
         if (offset + option->getHeaderLen() + opt_len > in_buffer.size()) {