Преглед изворни кода

A sonar warning stating these nested statements should be separate.

Bart Hertog пре 5 година
родитељ
комит
b9157c86de
2 измењених фајлова са 4 додато и 2 уклоњено
  1. 2 1
      src/Fields.cpp
  2. 2 1
      src/WireFormatter.h

+ 2 - 1
src/Fields.cpp

@@ -204,7 +204,8 @@ namespace EmbeddedProto
 
   Error boolean::serialize(WriteBufferInterface& buffer) const
   {
-    return buffer.push(get() ? 0x01 : 0x00) ? Error::NO_ERRORS : Error::BUFFER_FULL;
+    const uint8_t byte = get() ? 0x01 : 0x00;
+    return buffer.push(byte) ? Error::NO_ERRORS : Error::BUFFER_FULL;
   }
 
   Error fixed32::serialize(WriteBufferInterface& buffer) const

+ 2 - 1
src/WireFormatter.h

@@ -168,7 +168,8 @@ namespace EmbeddedProto
         Error return_value = SerializeVarint(MakeTag(field_number, WireType::VARINT), buffer);
         if(Error::NO_ERRORS == return_value)
         {
-          return_value = buffer.push(value ? 0x01 : 0x00) ? Error::NO_ERRORS : Error::BUFFER_FULL;
+          const uint8_t byte = value ? 0x01 : 0x00;
+          return_value = buffer.push(byte) ? Error::NO_ERRORS : Error::BUFFER_FULL;
         }
         return return_value;
       }