OSDN Git Service

Fix misc-macro-parentheses warnings in common_time.
authorChih-Hung Hsieh <chh@google.com>
Thu, 19 May 2016 22:21:42 +0000 (15:21 -0700)
committerChih-Hung Hsieh <chh@google.com>
Thu, 19 May 2016 22:21:42 +0000 (15:21 -0700)
Bug: 28705665
Change-Id: Ibdab4631f0e692b8a291faecdeb4a6062f906ea5

libs/common_time/common_time_server_api.cpp
libs/common_time/common_time_server_packets.cpp

index e0f35a9..60e6567 100644 (file)
@@ -285,7 +285,7 @@ void CommonTimeServer::reevaluateAutoDisableState(bool commonClockHasClients) {
     if (res > 0)                                  \
         write(fd, buffer, res);                   \
 } while (0)
-#define checked_percentage(a, b) ((0 == b) ? 0.0f : ((100.0f * a) / b))
+#define checked_percentage(a, b) ((0 == (b)) ? 0.0f : ((100.0f * (a)) / (b)))
 
 status_t CommonTimeServer::dumpClockInterface(int fd,
                                               const Vector<String16>& /* args */,
index 9833c37..c7c893d 100644 (file)
@@ -48,12 +48,12 @@ const uint16_t TimeServicePacketHeader::kCurVersion = 1;
 #define SERIALIZE_INT32(field_name) SERIALIZE_FIELD(field_name, int32_t, htonl)
 #define SERIALIZE_INT64(field_name) SERIALIZE_FIELD(field_name, int64_t, htonq)
 
-#define DESERIALIZE_FIELD(field_name, type, converter)      \
-    do {                                                    \
-        if ((offset + sizeof(field_name)) > length)         \
-            return -1;                                      \
-        field_name = converter(*((type*)(data + offset)));  \
-        offset += sizeof(field_name);                       \
+#define DESERIALIZE_FIELD(field_name, type, converter)       \
+    do {                                                     \
+        if ((offset + sizeof(field_name)) > length)          \
+            return -1;                                       \
+        (field_name) = converter(*((type*)(data + offset))); \
+        offset += sizeof(field_name);                        \
     } while (0)
 #define DESERIALIZE_INT16(field_name) DESERIALIZE_FIELD(field_name, int16_t, ntohs)
 #define DESERIALIZE_INT32(field_name) DESERIALIZE_FIELD(field_name, int32_t, ntohl)