From c713bce90183fa4ade82bc6f4b08280d32f1fb58 Mon Sep 17 00:00:00 2001 From: Chih-Hung Hsieh Date: Wed, 18 May 2016 15:59:37 -0700 Subject: [PATCH] Fix misc-macro-parentheses warnings in init and other core modules. Bug: 28705665 Change-Id: Ice67cebb8c42538f8fb9cf1756678f41a9d68a31 --- base/include/android-base/logging.h | 8 ++++---- fs_mgr/fs_mgr_priv_verity.h | 4 ++-- fs_mgr/include/fs_mgr.h | 6 +++--- init/ueventd_parser.cpp | 2 +- libcutils/strdup8to16.c | 2 +- libpixelflinger/codeflinger/disassem.c | 16 ++++++++-------- .../include/private/pixelflinger/ggl_context.h | 6 +++--- toolbox/bsd-compatibility.h | 2 +- 8 files changed, 23 insertions(+), 23 deletions(-) diff --git a/base/include/android-base/logging.h b/base/include/android-base/logging.h index b86c232eb..56e2ddeed 100644 --- a/base/include/android-base/logging.h +++ b/base/include/android-base/logging.h @@ -194,13 +194,13 @@ class ErrnoRestorer { // Helper for CHECK_STRxx(s1,s2) macros. #define CHECK_STROP(s1, s2, sense) \ - if (LIKELY((strcmp(s1, s2) == 0) == sense)) \ + if (LIKELY((strcmp(s1, s2) == 0) == (sense))) \ ; \ else \ ABORT_AFTER_LOG_FATAL \ LOG(FATAL) << "Check failed: " \ - << "\"" << s1 << "\"" \ - << (sense ? " == " : " != ") << "\"" << s2 << "\"" + << "\"" << (s1) << "\"" \ + << ((sense) ? " == " : " != ") << "\"" << (s2) << "\"" // Check for string (const char*) equality between s1 and s2, LOG(FATAL) if not. #define CHECK_STREQ(s1, s2) CHECK_STROP(s1, s2, true) @@ -213,7 +213,7 @@ class ErrnoRestorer { if (rc != 0) { \ errno = rc; \ ABORT_AFTER_LOG_FATAL \ - PLOG(FATAL) << #call << " failed for " << what; \ + PLOG(FATAL) << #call << " failed for " << (what); \ } \ } while (false) diff --git a/fs_mgr/fs_mgr_priv_verity.h b/fs_mgr/fs_mgr_priv_verity.h index cd673f386..d9e17bb54 100644 --- a/fs_mgr/fs_mgr_priv_verity.h +++ b/fs_mgr/fs_mgr_priv_verity.h @@ -16,8 +16,8 @@ #include -#define FS_MGR_SETUP_VERITY_DISABLED -2 -#define FS_MGR_SETUP_VERITY_FAIL -1 +#define FS_MGR_SETUP_VERITY_DISABLED (-2) +#define FS_MGR_SETUP_VERITY_FAIL (-1) #define FS_MGR_SETUP_VERITY_SUCCESS 0 __BEGIN_DECLS diff --git a/fs_mgr/include/fs_mgr.h b/fs_mgr/include/fs_mgr.h index c5e1f3286..b49861845 100644 --- a/fs_mgr/include/fs_mgr.h +++ b/fs_mgr/include/fs_mgr.h @@ -80,11 +80,11 @@ void fs_mgr_free_fstab(struct fstab *fstab); #define FS_MGR_MNTALL_DEV_NEEDS_ENCRYPTION 2 #define FS_MGR_MNTALL_DEV_MIGHT_BE_ENCRYPTED 1 #define FS_MGR_MNTALL_DEV_NOT_ENCRYPTED 0 -#define FS_MGR_MNTALL_FAIL -1 +#define FS_MGR_MNTALL_FAIL (-1) int fs_mgr_mount_all(struct fstab *fstab); -#define FS_MGR_DOMNT_FAILED -1 -#define FS_MGR_DOMNT_BUSY -2 +#define FS_MGR_DOMNT_FAILED (-1) +#define FS_MGR_DOMNT_BUSY (-2) int fs_mgr_do_mount(struct fstab *fstab, char *n_name, char *n_blk_device, char *tmp_mount_point); int fs_mgr_do_tmpfs_mount(char *n_name); diff --git a/init/ueventd_parser.cpp b/init/ueventd_parser.cpp index 09f463874..baff58c36 100644 --- a/init/ueventd_parser.cpp +++ b/init/ueventd_parser.cpp @@ -38,7 +38,7 @@ static void parse_line_device(struct parse_state *state, int nargs, char **args) #include "ueventd_keywords.h" #define KEYWORD(symbol, flags, nargs) \ - [ K_##symbol ] = { #symbol, nargs + 1, flags, }, + [ K_##symbol ] = { #symbol, (nargs) + 1, flags, }, static struct { const char *name; diff --git a/libcutils/strdup8to16.c b/libcutils/strdup8to16.c index 63e5ca48d..c23cf8b9a 100644 --- a/libcutils/strdup8to16.c +++ b/libcutils/strdup8to16.c @@ -27,7 +27,7 @@ #define UTF16_REPLACEMENT_CHAR 0xfffd /* Clever trick from Dianne that returns 1-4 depending on leading bit sequence*/ -#define UTF8_SEQ_LENGTH(ch) (((0xe5000000 >> ((ch >> 3) & 0x1e)) & 3) + 1) +#define UTF8_SEQ_LENGTH(ch) (((0xe5000000 >> (((ch) >> 3) & 0x1e)) & 3) + 1) /* note: macro expands to multiple lines */ #define UTF8_SHIFT_AND_MASK(unicode, byte) \ diff --git a/libpixelflinger/codeflinger/disassem.c b/libpixelflinger/codeflinger/disassem.c index 39dd61461..5cbd63db8 100644 --- a/libpixelflinger/codeflinger/disassem.c +++ b/libpixelflinger/codeflinger/disassem.c @@ -279,14 +279,14 @@ static char const insn_fpaconstants[][8] = { "4.0", "5.0", "0.5", "10.0" }; -#define insn_condition(x) arm32_insn_conditions[(x >> 28) & 0x0f] -#define insn_blktrans(x) insn_block_transfers[(x >> 23) & 3] -#define insn_stkblktrans(x) insn_stack_block_transfers[(3*((x >> 20)&1))^((x >> 23)&3)] -#define op2_shift(x) op_shifts[(x >> 5) & 3] -#define insn_fparnd(x) insn_fpa_rounding[(x >> 5) & 0x03] -#define insn_fpaprec(x) insn_fpa_precision[(((x >> 18) & 2)|(x >> 7)) & 1] -#define insn_fpaprect(x) insn_fpa_precision[(((x >> 21) & 2)|(x >> 15)) & 1] -#define insn_fpaimm(x) insn_fpaconstants[x & 0x07] +#define insn_condition(x) arm32_insn_conditions[((x) >> 28) & 0x0f] +#define insn_blktrans(x) insn_block_transfers[((x) >> 23) & 3] +#define insn_stkblktrans(x) insn_stack_block_transfers[(3*(((x) >> 20)&1))^(((x) >> 23)&3)] +#define op2_shift(x) op_shifts[((x) >> 5) & 3] +#define insn_fparnd(x) insn_fpa_rounding[((x) >> 5) & 0x03] +#define insn_fpaprec(x) insn_fpa_precision[((((x) >> 18) & 2)|((x) >> 7)) & 1] +#define insn_fpaprect(x) insn_fpa_precision[((((x) >> 21) & 2)|((x) >> 15)) & 1] +#define insn_fpaimm(x) insn_fpaconstants[(x) & 0x07] /* Local prototypes */ static void disasm_register_shift(const disasm_interface_t *di, u_int insn); diff --git a/libpixelflinger/include/private/pixelflinger/ggl_context.h b/libpixelflinger/include/private/pixelflinger/ggl_context.h index d45dabcd0..563b0f119 100644 --- a/libpixelflinger/include/private/pixelflinger/ggl_context.h +++ b/libpixelflinger/include/private/pixelflinger/ggl_context.h @@ -120,7 +120,7 @@ inline GGLcolor gglFixedToIteratedColor(GGLfixed c) { template struct CTA; template<> struct CTA { }; -#define GGL_CONTEXT(con, c) context_t *con = static_cast(c) +#define GGL_CONTEXT(con, c) context_t *(con) = static_cast(c) /* NOLINT */ #define GGL_OFFSETOF(field) uintptr_t(&(((context_t*)0)->field)) #define GGL_INIT_PROC(p, f) p.f = ggl_ ## f; #define GGL_BETWEEN(x, L, H) (uint32_t((x)-(L)) <= ((H)-(L))) @@ -136,14 +136,14 @@ const int GGL_PIXEL_PIPELINE_STATE = 0x00000004; // ---------------------------------------------------------------------------- #define GGL_RESERVE_NEEDS(name, l, s) \ - const uint32_t GGL_NEEDS_##name##_MASK = (((1LU<<(s))-1)<> GGL_NEEDS_##name##_SHIFT) + (uint32_t((n) & GGL_NEEDS_##name##_MASK) >> GGL_NEEDS_##name##_SHIFT) #define GGL_NEED_MASK(name) (uint32_t(GGL_NEEDS_##name##_MASK)) #define GGL_NEED(name, val) GGL_BUILD_NEEDS(val, name) diff --git a/toolbox/bsd-compatibility.h b/toolbox/bsd-compatibility.h index 434d37075..7c3ddd452 100644 --- a/toolbox/bsd-compatibility.h +++ b/toolbox/bsd-compatibility.h @@ -43,7 +43,7 @@ #define __type_fit(t, a) (0 == 0) // TODO: should this be in our ? -#define __arraycount(a) (sizeof(a) / sizeof(a[0])) +#define __arraycount(a) (sizeof(a) / sizeof((a)[0])) // This at least matches GNU dd(1) behavior. #define SIGINFO SIGUSR1