OSDN Git Service

[cherry-pick] Fix misc-macro-parentheses warnings in goldfish/opengl.
authorChih-Hung Hsieh <chh@google.com>
Thu, 9 Jun 2016 21:02:30 +0000 (14:02 -0700)
committerYahan Zhou <yahan@google.com>
Mon, 18 Jul 2016 17:36:36 +0000 (17:36 +0000)
Add parentheses around macro arguments used beside operators.
Use NOLINT to suppress warning or clang-tidy can put parentheses at
wrong places.

Bug: 28705665

cherry-pick from https://android-review.googlesource.com/#/c/237790/
Change-Id: I40653d3e617f84c07b308bb9c2869219f6563706
Test: build with clang-tidy

system/OpenglSystemCommon/HostConnection.cpp
system/egl/ClientAPIExts.cpp
system/egl/egl.cpp
system/egl/eglDisplay.h

index 180784e..4dcafca 100644 (file)
@@ -21,7 +21,7 @@
 #include "GLEncoder.h"
 #include "GL2Encoder.h"
 
-#define STREAM_BUFFER_SIZE  4*1024*1024
+#define STREAM_BUFFER_SIZE  (4*1024*1024)
 #define STREAM_PORT_NUM     22468
 
 /* Set to 1 to use a QEMU pipe, or 0 for a TCP connection */
index 5e81afe..a18754d 100644 (file)
@@ -27,11 +27,12 @@ namespace ClientAPIExts
 // typename has the form __egl_{funcname}_t
 //
 #define FUNC_TYPE(fname) __egl_ ## fname ## _t
+// NOLINT: clang-tidy adds parentheses around 'params'.
 #define API_ENTRY(fname,params,args) \
-    typedef void (GL_APIENTRY *FUNC_TYPE(fname)) params;
+    typedef void (GL_APIENTRY *FUNC_TYPE(fname)) params;  // NOLINT
 
 #define API_ENTRY_RET(rtype,fname,params,args) \
-    typedef rtype (GL_APIENTRY *FUNC_TYPE(fname)) params;
+    typedef rtype (GL_APIENTRY *FUNC_TYPE(fname)) params;  // NOLINT
 
 #include "ClientAPIExts.in"
 #undef API_ENTRY
@@ -44,7 +45,7 @@ namespace ClientAPIExts
 // loaded.
 /////
 #define API_ENTRY(fname,params,args) \
-    FUNC_TYPE(fname) fname;
+    FUNC_TYPE(fname) (fname);
 
 #define API_ENTRY_RET(rtype,fname,params,args) \
     API_ENTRY(fname,params,args)
@@ -88,6 +89,7 @@ void initClientFuncs(const EGLClient_glesInterface *iface, int idx)
 // the current context version and calls to the correct client API
 // function.
 //
+// NOLINT: clang-tidy adds parentheses around 'args'.
 #define API_ENTRY(fname,params,args) \
     static void _egl_ ## fname params \
     { \
@@ -99,7 +101,7 @@ void initClientFuncs(const EGLClient_glesInterface *iface, int idx)
         if (!s_client_extensions[idx].fname) { \
             return; \
         } \
-        (*s_client_extensions[idx].fname) args; \
+        (*s_client_extensions[idx].fname) args; /* NOLINT */ \
     }
 
 #define API_ENTRY_RET(rtype,fname,params,args) \
@@ -113,7 +115,7 @@ void initClientFuncs(const EGLClient_glesInterface *iface, int idx)
         if (!s_client_extensions[idx].fname) { \
             return (rtype)0; \
         } \
-        return (*s_client_extensions[idx].fname) args; \
+        return (*s_client_extensions[idx].fname) args; /* NOLINT */ \
     }
 
 #include "ClientAPIExts.in"
index 88d1143..87c3eb5 100644 (file)
@@ -98,7 +98,7 @@ const char *  eglStrError(EGLint err)
 #endif //LOG_EGL_ERRORS
 
 #define VALIDATE_CONFIG(cfg,ret) \
-    if(((intptr_t)cfg<0)||((intptr_t)cfg>s_display.getNumConfigs())) { \
+    if(((intptr_t)(cfg)<0)||((intptr_t)(cfg)>s_display.getNumConfigs())) { \
         RETURN_ERROR(ret,EGL_BAD_CONFIG); \
     }
 
@@ -129,13 +129,13 @@ const char *  eglStrError(EGLint err)
         return ret; \
     }
 
-#define VALIDATE_CONTEXT_RETURN(context,ret)        \
-    if (!context) {                                    \
+#define VALIDATE_CONTEXT_RETURN(context,ret)  \
+    if (!(context)) {                         \
         RETURN_ERROR(ret,EGL_BAD_CONTEXT);    \
     }
 
 #define VALIDATE_SURFACE_RETURN(surface, ret)    \
-    if (surface != EGL_NO_SURFACE) {    \
+    if ((surface) != EGL_NO_SURFACE) {    \
         egl_surface_t* s( static_cast<egl_surface_t*>(surface) );    \
         if (s->dpy != (EGLDisplay)&s_display)    \
             setErrorReturn(EGL_BAD_DISPLAY, EGL_FALSE);    \
index da33eb1..ba39201 100644 (file)
@@ -32,7 +32,7 @@
 
 #include <ui/PixelFormat.h>
 
-#define ATTRIBUTE_NONE -1
+#define ATTRIBUTE_NONE (-1)
 //FIXME: are we in this namespace?
 using namespace android;