[Bf-blender-cvs] [fe63124c3eb] master: Cleanup: add missing braces in GHOST

Campbell Barton noreply at git.blender.org
Fri Aug 12 03:13:39 CEST 2022


Commit: fe63124c3eb26dd2bcbe18ee678ea942cb12b4bf
Author: Campbell Barton
Date:   Fri Aug 12 11:12:37 2022 +1000
Branches: master
https://developer.blender.org/rBfe63124c3eb26dd2bcbe18ee678ea942cb12b4bf

Cleanup: add missing braces in GHOST

===================================================================

M	intern/ghost/intern/GHOST_Context.cpp
M	intern/ghost/intern/GHOST_NDOFManager.cpp
M	intern/ghost/intern/GHOST_SystemX11.cpp
M	intern/ghost/intern/GHOST_WindowX11.cpp
M	intern/ghost/test/gears/GHOST_Test.cpp
M	intern/ghost/test/multitest/MultiTest.c

===================================================================

diff --git a/intern/ghost/intern/GHOST_Context.cpp b/intern/ghost/intern/GHOST_Context.cpp
index 9dd417521eb..f4b3d08ffc5 100644
--- a/intern/ghost/intern/GHOST_Context.cpp
+++ b/intern/ghost/intern/GHOST_Context.cpp
@@ -113,8 +113,9 @@ bool win32_chk(bool result, const char *file, int line, const char *text)
 
     SetLastError(NO_ERROR);
 
-    if (count != 0)
+    if (count != 0) {
       LocalFree(formattedMsg);
+    }
   }
 
   return result;
diff --git a/intern/ghost/intern/GHOST_NDOFManager.cpp b/intern/ghost/intern/GHOST_NDOFManager.cpp
index d58fb90f63e..746e3532b03 100644
--- a/intern/ghost/intern/GHOST_NDOFManager.cpp
+++ b/intern/ghost/intern/GHOST_NDOFManager.cpp
@@ -411,8 +411,9 @@ static bool nearHomePosition(GHOST_TEventNDOFMotionData *ndof, float threshold)
 
 bool GHOST_NDOFManager::sendMotionEvent()
 {
-  if (!m_motionEventPending)
+  if (!m_motionEventPending) {
     return false;
+  }
 
   m_motionEventPending = false; /* Any pending motion is handled right now. */
 
diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp
index 51e4c3b2849..07d8b02f8ad 100644
--- a/intern/ghost/intern/GHOST_SystemX11.cpp
+++ b/intern/ghost/intern/GHOST_SystemX11.cpp
@@ -514,8 +514,9 @@ static void destroyIMCallback(XIM /*xim*/, XPointer ptr, XPointer /*data*/)
 
 bool GHOST_SystemX11::openX11_IM()
 {
-  if (!m_display)
+  if (!m_display) {
     return false;
+  }
 
   /* set locale modifiers such as `@im=ibus` specified by XMODIFIERS. */
   XSetLocaleModifiers("");
@@ -585,7 +586,7 @@ struct init_timestamp_data {
   Time timestamp;
 };
 
-static Bool init_timestamp_scanner(Display *, XEvent *event, XPointer arg)
+static Bool init_timestamp_scanner(Display * /*display*/, XEvent *event, XPointer arg)
 {
   init_timestamp_data *data = reinterpret_cast<init_timestamp_data *>(arg);
   switch (event->type) {
@@ -1321,10 +1322,12 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
 #if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
       XIC xic = window->getX11_XIC();
       if (xic) {
-        if (xe->type == FocusIn)
+        if (xe->type == FocusIn) {
           XSetICFocus(xic);
-        else
+        }
+        else {
           XUnsetICFocus(xic);
+        }
       }
 #endif
 
diff --git a/intern/ghost/intern/GHOST_WindowX11.cpp b/intern/ghost/intern/GHOST_WindowX11.cpp
index 2276e90387b..83c608435b0 100644
--- a/intern/ghost/intern/GHOST_WindowX11.cpp
+++ b/intern/ghost/intern/GHOST_WindowX11.cpp
@@ -147,16 +147,19 @@ static XVisualInfo *x11_visualinfo_from_glx(Display *display,
       /* take a frame buffer config that has alpha cap */
       for (int i = 0; i < nbfbconfig; i++) {
         XVisualInfo *visual = (XVisualInfo *)glXGetVisualFromFBConfig(display, fbconfigs[i]);
-        if (!visual)
+        if (!visual) {
           continue;
+        }
         /* if we don't need a alpha background, the first config will do, otherwise
          * test the alphaMask as it won't necessarily be present */
         if (needAlpha) {
           XRenderPictFormat *pict_format = XRenderFindVisualFormat(display, visual->visual);
-          if (!pict_format)
+          if (!pict_format) {
             continue;
-          if (pict_format->direct.alphaMask <= 0)
+          }
+          if (pict_format->direct.alphaMask <= 0) {
             continue;
+          }
         }
 
         *fbconfig = fbconfigs[i];
@@ -487,8 +490,9 @@ static Bool destroyICCallback(XIC /*xic*/, XPointer ptr, XPointer /*data*/)
 bool GHOST_WindowX11::createX11_XIC()
 {
   XIM xim = m_system->getX11_XIM();
-  if (!xim)
+  if (!xim) {
     return false;
+  }
 
   XICCallback destroy;
   destroy.callback = (XICProc)destroyICCallback;
@@ -536,17 +540,21 @@ void GHOST_WindowX11::refreshXInputDevices()
       XEventClass ev;
 
       DeviceMotionNotify(xtablet.Device, xtablet.MotionEvent, ev);
-      if (ev)
+      if (ev) {
         xevents.push_back(ev);
+      }
       DeviceButtonPress(xtablet.Device, xtablet.PressEvent, ev);
-      if (ev)
+      if (ev) {
         xevents.push_back(ev);
+      }
       ProximityIn(xtablet.Device, xtablet.ProxInEvent, ev);
-      if (ev)
+      if (ev) {
         xevents.push_back(ev);
+      }
       ProximityOut(xtablet.Device, xtablet.ProxOutEvent, ev);
-      if (ev)
+      if (ev) {
         xevents.push_back(ev);
+      }
     }
 
     XSelectExtensionEvent(m_display, m_window, xevents.data(), (int)xevents.size());
diff --git a/intern/ghost/test/gears/GHOST_Test.cpp b/intern/ghost/test/gears/GHOST_Test.cpp
index 5a43543d163..f5ef2527d75 100644
--- a/intern/ghost/test/gears/GHOST_Test.cpp
+++ b/intern/ghost/test/gears/GHOST_Test.cpp
@@ -559,10 +559,12 @@ bool Application::processEvent(GHOST_IEvent *event)
           break;
 
         case GHOST_kKeyS:  // toggle mono and stereo
-          if (stereo)
+          if (stereo) {
             stereo = false;
-          else
+          }
+          else {
             stereo = true;
+          }
           break;
 
         case GHOST_kKeyT:
@@ -680,8 +682,9 @@ int main(int /*argc*/, char ** /*argv*/)
     if (lresult == ERROR_SUCCESS)
       printf("Successfully set value for key\n");
     regkey.Close();
-    if (lresult == ERROR_SUCCESS)
+    if (lresult == ERROR_SUCCESS) {
       printf("Successfully closed key\n");
+    }
     //      regkey.Write("2");
   }
 #endif  // WIN32
diff --git a/intern/ghost/test/multitest/MultiTest.c b/intern/ghost/test/multitest/MultiTest.c
index 157e4f1b0f2..99b88dfb525 100644
--- a/intern/ghost/test/multitest/MultiTest.c
+++ b/intern/ghost/test/multitest/MultiTest.c
@@ -179,37 +179,44 @@ static void mainwindow_do_key(MainWindow *mw, GHOST_TKey key, int press)
 {
   switch (key) {
     case GHOST_kKeyC:
-      if (press)
+      if (press) {
         GHOST_SetCursorShape(mw->win,
                              (GHOST_TStandardCursor)(rand() % (GHOST_kStandardCursorNumCursors)));
+      }
       break;
     case GHOST_kKeyLeftBracket:
-      if (press)
+      if (press) {
         GHOST_SetCursorVisibility(mw->win, 0);
+      }
       break;
     case GHOST_kKeyRightBracket:
-      if (press)
+      if (press) {
         GHOST_SetCursorVisibility(mw->win, 1);
+      }
       break;
     case GHOST_kKeyE:
-      if (press)
+      if (press) {
         multitestapp_toggle_extra_window(mw->app);
+      }
       break;
     case GHOST_kKeyQ:
-      if (press)
+      if (press) {
         multitestapp_exit(mw->app);
+      }
       break;
     case GHOST_kKeyT:
-      if (press)
+      if (press) {
         mainwindow_log(mw, "TextTest~|`hello`\"world\",<>/");
+      }
       break;
     case GHOST_kKeyR:
       if (press) {
         int i;
 
         mainwindow_log(mw, "Invalidating window 10 times");
-        for (i = 0; i < 10; i++)
+        for (i = 0; i < 10; i++) {
           GHOST_InvalidateWindow(mw->win);
+        }
       }
       break;
     case GHOST_kKeyF11:
@@ -328,9 +335,7 @@ MainWindow *mainwindow_new(MultiTestApp *app)
 
     return mw;
   }
-  else {
-    return NULL;
-  }
+  return NULL;
 }
 
 void mainwindow_free(MainWindow *mw)



More information about the Bf-blender-cvs mailing list