Merge "Fix misc-macro-parentheses warnings in openmax."
diff --git a/cmds/dumpstate/Android.mk b/cmds/dumpstate/Android.mk
index 4d00d53..4560415 100644
--- a/cmds/dumpstate/Android.mk
+++ b/cmds/dumpstate/Android.mk
@@ -14,7 +14,7 @@
LOCAL_MODULE := dumpstate
-LOCAL_SHARED_LIBRARIES := libcutils liblog libselinux
+LOCAL_SHARED_LIBRARIES := libcutils liblog libselinux libbase
LOCAL_HAL_STATIC_LIBRARIES := libdumpstate
LOCAL_CFLAGS += -Wall -Werror -Wno-unused-parameter
LOCAL_INIT_RC := dumpstate.rc
diff --git a/cmds/dumpstate/utils.cpp b/cmds/dumpstate/utils.cpp
index d2d717a..f5183d1 100644
--- a/cmds/dumpstate/utils.cpp
+++ b/cmds/dumpstate/utils.cpp
@@ -33,6 +33,7 @@
#include <unistd.h>
#include <sys/prctl.h>
+#include <android-base/file.h>
#include <cutils/debugger.h>
#include <cutils/properties.h>
#include <cutils/sockets.h>
@@ -923,52 +924,38 @@
}
void dump_emmc_ecsd(const char *ext_csd_path) {
- static const size_t EXT_CSD_REV = 192;
- static const size_t EXT_PRE_EOL_INFO = 267;
- static const size_t EXT_DEVICE_LIFE_TIME_EST_TYP_A = 268;
- static const size_t EXT_DEVICE_LIFE_TIME_EST_TYP_B = 269;
+ // List of interesting offsets
struct hex {
char str[2];
- } buffer[512];
- int fd, ext_csd_rev, ext_pre_eol_info;
- ssize_t bytes_read;
- static const char *ver_str[] = {
- "4.0", "4.1", "4.2", "4.3", "Obsolete", "4.41", "4.5", "5.0"
};
- static const char *eol_str[] = {
- "Undefined",
- "Normal",
- "Warning (consumed 80% of reserve)",
- "Urgent (consumed 90% of reserve)"
- };
+ static const size_t EXT_CSD_REV = 192 * sizeof(hex);
+ static const size_t EXT_PRE_EOL_INFO = 267 * sizeof(hex);
+ static const size_t EXT_DEVICE_LIFE_TIME_EST_TYP_A = 268 * sizeof(hex);
+ static const size_t EXT_DEVICE_LIFE_TIME_EST_TYP_B = 269 * sizeof(hex);
+
+ std::string buffer;
+ if (!android::base::ReadFileToString(ext_csd_path, &buffer)) {
+ return;
+ }
printf("------ %s Extended CSD ------\n", ext_csd_path);
- fd = TEMP_FAILURE_RETRY(open(ext_csd_path,
- O_RDONLY | O_NONBLOCK | O_CLOEXEC));
- if (fd < 0) {
- printf("*** %s: %s\n\n", ext_csd_path, strerror(errno));
+ if (buffer.length() < (EXT_CSD_REV + sizeof(hex))) {
+ printf("*** %s: truncated content %zu\n\n", ext_csd_path, buffer.length());
return;
}
- bytes_read = TEMP_FAILURE_RETRY(read(fd, buffer, sizeof(buffer)));
- close(fd);
- if (bytes_read < 0) {
- printf("*** %s: %s\n\n", ext_csd_path, strerror(errno));
- return;
- }
- if (bytes_read < (ssize_t)(EXT_CSD_REV * sizeof(struct hex))) {
- printf("*** %s: truncated content %zd\n\n", ext_csd_path, bytes_read);
+ int ext_csd_rev = 0;
+ std::string sub = buffer.substr(EXT_CSD_REV, sizeof(hex));
+ if (sscanf(sub.c_str(), "%2x", &ext_csd_rev) != 1) {
+ printf("*** %s: EXT_CSD_REV parse error \"%s\"\n\n",
+ ext_csd_path, sub.c_str());
return;
}
- ext_csd_rev = 0;
- if (sscanf(buffer[EXT_CSD_REV].str, "%02x", &ext_csd_rev) != 1) {
- printf("*** %s: EXT_CSD_REV parse error \"%.2s\"\n\n",
- ext_csd_path, buffer[EXT_CSD_REV].str);
- return;
- }
-
+ static const char *ver_str[] = {
+ "4.0", "4.1", "4.2", "4.3", "Obsolete", "4.41", "4.5", "5.0"
+ };
printf("rev 1.%d (MMC %s)\n",
ext_csd_rev,
(ext_csd_rev < (int)(sizeof(ver_str) / sizeof(ver_str[0]))) ?
@@ -979,17 +966,25 @@
return;
}
- if (bytes_read < (ssize_t)(EXT_PRE_EOL_INFO * sizeof(struct hex))) {
- printf("*** %s: truncated content %zd\n\n", ext_csd_path, bytes_read);
+ if (buffer.length() < (EXT_PRE_EOL_INFO + sizeof(hex))) {
+ printf("*** %s: truncated content %zu\n\n", ext_csd_path, buffer.length());
return;
}
- ext_pre_eol_info = 0;
- if (sscanf(buffer[EXT_PRE_EOL_INFO].str, "%02x", &ext_pre_eol_info) != 1) {
- printf("*** %s: PRE_EOL_INFO parse error \"%.2s\"\n\n",
- ext_csd_path, buffer[EXT_PRE_EOL_INFO].str);
+ int ext_pre_eol_info = 0;
+ sub = buffer.substr(EXT_PRE_EOL_INFO, sizeof(hex));
+ if (sscanf(sub.c_str(), "%2x", &ext_pre_eol_info) != 1) {
+ printf("*** %s: PRE_EOL_INFO parse error \"%s\"\n\n",
+ ext_csd_path, sub.c_str());
return;
}
+
+ static const char *eol_str[] = {
+ "Undefined",
+ "Normal",
+ "Warning (consumed 80% of reserve)",
+ "Urgent (consumed 90% of reserve)"
+ };
printf("PRE_EOL_INFO %d (MMC %s)\n",
ext_pre_eol_info,
eol_str[(ext_pre_eol_info < (int)
@@ -998,7 +993,7 @@
for (size_t lifetime = EXT_DEVICE_LIFE_TIME_EST_TYP_A;
lifetime <= EXT_DEVICE_LIFE_TIME_EST_TYP_B;
- ++lifetime) {
+ lifetime += sizeof(hex)) {
int ext_device_life_time_est;
static const char *est_str[] = {
"Undefined",
@@ -1015,21 +1010,24 @@
"Exceeded the maximum estimated device lifetime",
};
- if (bytes_read < (ssize_t)(lifetime * sizeof(struct hex))) {
- printf("*** %s: truncated content %zd\n", ext_csd_path, bytes_read);
+ if (buffer.length() < (lifetime + sizeof(hex))) {
+ printf("*** %s: truncated content %zu\n", ext_csd_path, buffer.length());
break;
}
ext_device_life_time_est = 0;
- if (sscanf(buffer[lifetime].str, "%02x", &ext_device_life_time_est) != 1) {
- printf("*** %s: DEVICE_LIFE_TIME_EST_TYP_%c parse error \"%.2s\"\n",
+ sub = buffer.substr(lifetime, sizeof(hex));
+ if (sscanf(sub.c_str(), "%2x", &ext_device_life_time_est) != 1) {
+ printf("*** %s: DEVICE_LIFE_TIME_EST_TYP_%c parse error \"%s\"\n",
ext_csd_path,
- (unsigned)(lifetime - EXT_DEVICE_LIFE_TIME_EST_TYP_A) + 'A',
- buffer[lifetime].str);
+ (unsigned)((lifetime - EXT_DEVICE_LIFE_TIME_EST_TYP_A) /
+ sizeof(hex)) + 'A',
+ sub.c_str());
continue;
}
printf("DEVICE_LIFE_TIME_EST_TYP_%c %d (MMC %s)\n",
- (unsigned)(lifetime - EXT_DEVICE_LIFE_TIME_EST_TYP_A) + 'A',
+ (unsigned)((lifetime - EXT_DEVICE_LIFE_TIME_EST_TYP_A) /
+ sizeof(hex)) + 'A',
ext_device_life_time_est,
est_str[(ext_device_life_time_est < (int)
(sizeof(est_str) / sizeof(est_str[0]))) ?
diff --git a/include/binder/IInterface.h b/include/binder/IInterface.h
index 4ce3613..48c8b3b 100644
--- a/include/binder/IInterface.h
+++ b/include/binder/IInterface.h
@@ -105,7 +105,7 @@
#define CHECK_INTERFACE(interface, data, reply) \
- if (!data.checkInterface(this)) { return PERMISSION_DENIED; } \
+ if (!(data).checkInterface(this)) { return PERMISSION_DENIED; } \
// ----------------------------------------------------------------------
diff --git a/libs/binder/PersistableBundle.cpp b/libs/binder/PersistableBundle.cpp
index a20359f..5c5651c 100644
--- a/libs/binder/PersistableBundle.cpp
+++ b/libs/binder/PersistableBundle.cpp
@@ -91,7 +91,7 @@
#define RETURN_IF_ENTRY_ERASED(map, key) \
{ \
- size_t num_erased = map.erase(key); \
+ size_t num_erased = (map).erase(key); \
if (num_erased) { \
ALOGE("Failed at %s:%d (%s)", __FILE__, __LINE__, __func__); \
return num_erased; \
diff --git a/libs/gui/tests/CpuConsumer_test.cpp b/libs/gui/tests/CpuConsumer_test.cpp
index 2dc9ccc..5d53afc 100644
--- a/libs/gui/tests/CpuConsumer_test.cpp
+++ b/libs/gui/tests/CpuConsumer_test.cpp
@@ -160,7 +160,7 @@
};
#define ASSERT_NO_ERROR(err, msg) \
- ASSERT_EQ(NO_ERROR, err) << msg << strerror(-err)
+ ASSERT_EQ(NO_ERROR, err) << (msg) << strerror(-(err))
void checkPixel(const CpuConsumer::LockedBuffer &buf,
uint32_t x, uint32_t y, uint32_t r, uint32_t g=0, uint32_t b=0) {
diff --git a/libs/input/tests/StructLayout_test.cpp b/libs/input/tests/StructLayout_test.cpp
index 8d73f45..81b9953 100644
--- a/libs/input/tests/StructLayout_test.cpp
+++ b/libs/input/tests/StructLayout_test.cpp
@@ -20,7 +20,7 @@
namespace android {
#define CHECK_OFFSET(type, member, expected_offset) \
- static_assert((offsetof(type, member) == expected_offset), "")
+ static_assert((offsetof(type, member) == (expected_offset)), "")
struct Foo {
uint32_t dummy;
diff --git a/opengl/libs/EGL/trace.cpp b/opengl/libs/EGL/trace.cpp
index 4f07053..248a1a0 100644
--- a/opengl/libs/EGL/trace.cpp
+++ b/opengl/libs/EGL/trace.cpp
@@ -409,7 +409,7 @@
#define CHECK_ERROR(_c, _api) \
GLenum status = GL_NO_ERROR; \
bool error = false; \
- while ((status = _c->glGetError()) != GL_NO_ERROR) { \
+ while ((status = (_c)->glGetError()) != GL_NO_ERROR) { \
ALOGD("[" #_api "] 0x%x", status); \
error = true; \
} \
diff --git a/opengl/libs/hooks.h b/opengl/libs/hooks.h
index 3f36b7d..5010776 100644
--- a/opengl/libs/hooks.h
+++ b/opengl/libs/hooks.h
@@ -55,8 +55,8 @@
#undef GL_ENTRY
#undef EGL_ENTRY
-#define GL_ENTRY(_r, _api, ...) _r (*_api)(__VA_ARGS__);
-#define EGL_ENTRY(_r, _api, ...) _r (*_api)(__VA_ARGS__);
+#define GL_ENTRY(_r, _api, ...) _r (*(_api))(__VA_ARGS__);
+#define EGL_ENTRY(_r, _api, ...) _r (*(_api))(__VA_ARGS__);
struct egl_t {
#include "EGL/egl_entries.in"
diff --git a/opengl/tests/angeles/demo.c b/opengl/tests/angeles/demo.c
index 802f398..39d871e 100644
--- a/opengl/tests/angeles/demo.c
+++ b/opengl/tests/angeles/demo.c
@@ -666,7 +666,7 @@
y[2] /= mag;
}
-#define M(row,col) m[col*4+row]
+#define M(row,col) m[(col)*4+(row)]
M(0, 0) = x[0];
M(0, 1) = x[1];
M(0, 2) = x[2];
diff --git a/opengl/tests/hwc/hwcColorEquiv.cpp b/opengl/tests/hwc/hwcColorEquiv.cpp
index 06a0191..085f374 100644
--- a/opengl/tests/hwc/hwcColorEquiv.cpp
+++ b/opengl/tests/hwc/hwcColorEquiv.cpp
@@ -115,7 +115,7 @@
#define CMD_START_FRAMEWORK "start 2>&1"
// Macros
-#define NUMA(a) (sizeof(a) / sizeof(a [0])) // Num elements in an array
+#define NUMA(a) (sizeof(a) / sizeof((a)[0])) // Num elements in an array
#define MEMCLR(addr, size) do { \
memset((addr), 0, (size)); \
} while (0)
diff --git a/opengl/tests/hwc/hwcCommit.cpp b/opengl/tests/hwc/hwcCommit.cpp
index 5d7f810..6005b99 100644
--- a/opengl/tests/hwc/hwcCommit.cpp
+++ b/opengl/tests/hwc/hwcCommit.cpp
@@ -157,7 +157,7 @@
#define CMD_START_FRAMEWORK "start 2>&1"
// Macros
-#define NUMA(a) (sizeof(a) / sizeof(a [0])) // Num elements in an array
+#define NUMA(a) (sizeof(a) / sizeof((a)[0])) // Num elements in an array
// Local types
class Rectangle {
diff --git a/opengl/tests/hwc/hwcRects.cpp b/opengl/tests/hwc/hwcRects.cpp
index 56c1a2a..ba242ab 100644
--- a/opengl/tests/hwc/hwcRects.cpp
+++ b/opengl/tests/hwc/hwcRects.cpp
@@ -137,7 +137,7 @@
#define CMD_START_FRAMEWORK "start 2>&1"
// Macros
-#define NUMA(a) (sizeof(a) / sizeof(a [0])) // Num elements in an array
+#define NUMA(a) (sizeof(a) / sizeof((a)[0])) // Num elements in an array
// Local types
class Rectangle {
diff --git a/opengl/tests/hwc/hwcStress.cpp b/opengl/tests/hwc/hwcStress.cpp
index b1d6c76..e6e5194 100644
--- a/opengl/tests/hwc/hwcStress.cpp
+++ b/opengl/tests/hwc/hwcStress.cpp
@@ -161,7 +161,7 @@
#define CMD_STOP_FRAMEWORK "stop 2>&1"
#define CMD_START_FRAMEWORK "start 2>&1"
-#define NUMA(a) (sizeof(a) / sizeof(a [0]))
+#define NUMA(a) (sizeof(a) / sizeof((a)[0]))
#define MEMCLR(addr, size) do { \
memset((addr), 0, (size)); \
} while (0)
diff --git a/services/inputflinger/EventHub.cpp b/services/inputflinger/EventHub.cpp
index 5859606..3958c8b 100644
--- a/services/inputflinger/EventHub.cpp
+++ b/services/inputflinger/EventHub.cpp
@@ -55,10 +55,10 @@
* operation with a byte that only has the relevant bit set.
* eg. to check for the 12th bit, we do (array[1] & 1<<4)
*/
-#define test_bit(bit, array) (array[bit/8] & (1<<(bit%8)))
+#define test_bit(bit, array) ((array)[(bit)/8] & (1<<((bit)%8)))
/* this macro computes the number of bytes needed to represent a bit array of the specified size */
-#define sizeof_bit_array(bits) ((bits + 7) / 8)
+#define sizeof_bit_array(bits) (((bits) + 7) / 8)
#define INDENT " "
#define INDENT2 " "
diff --git a/services/sensorservice/SensorService.h b/services/sensorservice/SensorService.h
index 9a573ae..6df0aae 100644
--- a/services/sensorservice/SensorService.h
+++ b/services/sensorservice/SensorService.h
@@ -49,9 +49,9 @@
#define DEBUG_CONNECTIONS false
// Max size is 100 KB which is enough to accept a batch of about 1000 events.
-#define MAX_SOCKET_BUFFER_SIZE_BATCHED 100 * 1024
+#define MAX_SOCKET_BUFFER_SIZE_BATCHED (100 * 1024)
// For older HALs which don't support batching, use a smaller socket buffer size.
-#define SOCKET_BUFFER_SIZE_NON_BATCHED 4 * 1024
+#define SOCKET_BUFFER_SIZE_NON_BATCHED (4 * 1024)
#define CIRCULAR_BUF_SIZE 10
#define SENSOR_REGISTRATIONS_BUF_SIZE 20