Code style fixes, etc. Reference PR #6345.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
diff --git a/src/SDL.c b/src/SDL.c
index 42ebc2c..6297159 100644
--- a/src/SDL.c
+++ b/src/SDL.c
@@ -124,18 +124,19 @@ static Uint8 SDL_SubsystemRefCount[ 32 ];
static void
SDL_PrivateSubsystemRefCountIncr(Uint32 subsystem)
{
- int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
- SDL_assert(subsystem_index < 0 || SDL_SubsystemRefCount[subsystem_index] < 255);
- if (subsystem_index >= 0)
+ const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
+ SDL_assert((subsystem_index < 0) || (SDL_SubsystemRefCount[subsystem_index] < 255));
+ if (subsystem_index >= 0) {
++SDL_SubsystemRefCount[subsystem_index];
+ }
}
/* Private helper to decrement a subsystem's ref counter. */
static void
SDL_PrivateSubsystemRefCountDecr(Uint32 subsystem)
{
- int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
- if (subsystem_index >= 0 && SDL_SubsystemRefCount[subsystem_index] > 0) {
+ const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
+ if ((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] > 0)) {
--SDL_SubsystemRefCount[subsystem_index];
}
}
@@ -144,23 +145,23 @@ SDL_PrivateSubsystemRefCountDecr(Uint32 subsystem)
static SDL_bool
SDL_PrivateShouldInitSubsystem(Uint32 subsystem)
{
- int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
- SDL_assert(subsystem_index < 0 || SDL_SubsystemRefCount[subsystem_index] < 255);
- return (subsystem_index >= 0 && SDL_SubsystemRefCount[subsystem_index] == 0) ? SDL_TRUE : SDL_FALSE;
+ const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
+ SDL_assert((subsystem_index < 0) || (SDL_SubsystemRefCount[subsystem_index] < 255));
+ return ((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] == 0)) ? SDL_TRUE : SDL_FALSE;
}
/* Private helper to check if a system needs to be quit. */
static SDL_bool
SDL_PrivateShouldQuitSubsystem(Uint32 subsystem) {
- int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
- if (subsystem_index >= 0 && SDL_SubsystemRefCount[subsystem_index] == 0) {
- return SDL_FALSE;
+ const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
+ if ((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] == 0)) {
+ return SDL_FALSE;
}
/* If we're in SDL_Quit, we shut down every subsystem, even if refcount
* isn't zero.
*/
- return ((subsystem_index >= 0 && SDL_SubsystemRefCount[subsystem_index] == 1) || SDL_bInMainQuit) ? SDL_TRUE : SDL_FALSE;
+ return (((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] == 1)) || SDL_bInMainQuit) ? SDL_TRUE : SDL_FALSE;
}
void
diff --git a/src/joystick/hidapi/SDL_hidapi_shield.c b/src/joystick/hidapi/SDL_hidapi_shield.c
index 557ca45..4fe0090 100644
--- a/src/joystick/hidapi/SDL_hidapi_shield.c
+++ b/src/joystick/hidapi/SDL_hidapi_shield.c
@@ -169,8 +169,9 @@ HIDAPI_DriverShield_SendCommand(SDL_HIDAPI_Device *device, Uint8 cmd, const void
}
/* Zero unused data in the payload */
- if (size != sizeof(cmd_pkt.payload))
+ if (size != sizeof(cmd_pkt.payload)) {
SDL_memset(&cmd_pkt.payload[size], 0, sizeof(cmd_pkt.payload) - size);
+ }
if (SDL_HIDAPI_SendRumbleAndUnlock(device, (Uint8*)&cmd_pkt, sizeof(cmd_pkt)) != sizeof(cmd_pkt)) {
return SDL_SetError("Couldn't send command packet");
diff --git a/src/video/SDL_yuv.c b/src/video/SDL_yuv.c
index b163216..38cf9e7 100644
--- a/src/video/SDL_yuv.c
+++ b/src/video/SDL_yuv.c
@@ -603,8 +603,10 @@ SDL_ConvertPixels_ARGB8888_to_YUV(int width, int height, const void *src, int sr
if (GetYUVPlanes(width, height, dst_format, dst, dst_pitch,
(const Uint8 **)&plane_y, (const Uint8 **)&plane_u, (const Uint8 **)&plane_v,
- &y_stride, &uv_stride) != 0)
+ &y_stride, &uv_stride) != 0) {
return -1;
+ }
+
plane_interleaved_uv = (plane_y + height * y_stride);
y_skip = (y_stride - width);
diff --git a/src/video/windows/SDL_windowskeyboard.c b/src/video/windows/SDL_windowskeyboard.c
index 3a9988d..83a939d 100644
--- a/src/video/windows/SDL_windowskeyboard.c
+++ b/src/video/windows/SDL_windowskeyboard.c
@@ -398,8 +398,7 @@ IME_Init(SDL_VideoData *videodata, HWND hwnd)
if (SUCCEEDED(WIN_CoInitialize())) {
videodata->ime_com_initialized = SDL_TRUE;
hResult = CoCreateInstance(&CLSID_TF_ThreadMgr, NULL, CLSCTX_INPROC_SERVER, &IID_ITfThreadMgr, (LPVOID *)&videodata->ime_threadmgr);
- if (hResult != S_OK)
- {
+ if (hResult != S_OK) {
videodata->ime_available = SDL_FALSE;
SDL_SetError("CoCreateInstance() failed, HRESULT is %08X", (unsigned int)hResult);
return;
diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c
index d74f1dd..d260f15 100644
--- a/src/video/windows/SDL_windowswindow.c
+++ b/src/video/windows/SDL_windowswindow.c
@@ -739,18 +739,22 @@ WIN_GetWindowBordersSize(_THIS, SDL_Window * window, int *top, int *left, int *b
/* rcClient stores the size of the inner window, while rcWindow stores the outer size relative to the top-left
* screen position; so the top/left values of rcClient are always {0,0} and bottom/right are {height,width} */
- if (!GetClientRect(hwnd, &rcClient))
- SDL_SetError("GetClientRect() failed, error %08X", (unsigned int)GetLastError());
- if (!GetWindowRect(hwnd, &rcWindow))
- SDL_SetError("GetWindowRect() failed, error %08X", (unsigned int)GetLastError());
+ if (!GetClientRect(hwnd, &rcClient)) {
+ return SDL_SetError("GetClientRect() failed, error %08X", (unsigned int)GetLastError());
+ }
+
+ if (!GetWindowRect(hwnd, &rcWindow)) {
+ return SDL_SetError("GetWindowRect() failed, error %08X", (unsigned int)GetLastError());
+ }
/* convert the top/left values to make them relative to
* the window; they will end up being slightly negative */
ptDiff.y = rcWindow.top;
ptDiff.x = rcWindow.left;
- if (!ScreenToClient(hwnd, &ptDiff))
- SDL_SetError("ScreenToClient() failed, error %08X", (unsigned int)GetLastError());
+ if (!ScreenToClient(hwnd, &ptDiff)) {
+ return SDL_SetError("ScreenToClient() failed, error %08X", (unsigned int)GetLastError());
+ }
rcWindow.top = ptDiff.y;
rcWindow.left = ptDiff.x;
@@ -760,8 +764,9 @@ WIN_GetWindowBordersSize(_THIS, SDL_Window * window, int *top, int *left, int *b
ptDiff.y = rcWindow.bottom;
ptDiff.x = rcWindow.right;
- if (!ScreenToClient(hwnd, &ptDiff))
- SDL_SetError("ScreenToClient() failed, error %08X", (unsigned int)GetLastError());
+ if (!ScreenToClient(hwnd, &ptDiff)) {
+ return SDL_SetError("ScreenToClient() failed, error %08X", (unsigned int)GetLastError());
+ }
rcWindow.bottom = ptDiff.y;
rcWindow.right = ptDiff.x;