Skip to content

Commit 389ffab

Browse files
committed
Code style fixes, etc.
Reference PR #6345.
1 parent ec58a81 commit 389ffab

File tree

5 files changed

+32
-24
lines changed

5 files changed

+32
-24
lines changed

src/SDL.c

+13-12
Original file line numberDiff line numberDiff line change
@@ -124,18 +124,19 @@ static Uint8 SDL_SubsystemRefCount[ 32 ];
124124
static void
125125
SDL_PrivateSubsystemRefCountIncr(Uint32 subsystem)
126126
{
127-
int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
128-
SDL_assert(subsystem_index < 0 || SDL_SubsystemRefCount[subsystem_index] < 255);
129-
if (subsystem_index >= 0)
127+
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
128+
SDL_assert((subsystem_index < 0) || (SDL_SubsystemRefCount[subsystem_index] < 255));
129+
if (subsystem_index >= 0) {
130130
++SDL_SubsystemRefCount[subsystem_index];
131+
}
131132
}
132133

133134
/* Private helper to decrement a subsystem's ref counter. */
134135
static void
135136
SDL_PrivateSubsystemRefCountDecr(Uint32 subsystem)
136137
{
137-
int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
138-
if (subsystem_index >= 0 && SDL_SubsystemRefCount[subsystem_index] > 0) {
138+
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
139+
if ((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] > 0)) {
139140
--SDL_SubsystemRefCount[subsystem_index];
140141
}
141142
}
@@ -144,23 +145,23 @@ SDL_PrivateSubsystemRefCountDecr(Uint32 subsystem)
144145
static SDL_bool
145146
SDL_PrivateShouldInitSubsystem(Uint32 subsystem)
146147
{
147-
int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
148-
SDL_assert(subsystem_index < 0 || SDL_SubsystemRefCount[subsystem_index] < 255);
149-
return (subsystem_index >= 0 && SDL_SubsystemRefCount[subsystem_index] == 0) ? SDL_TRUE : SDL_FALSE;
148+
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
149+
SDL_assert((subsystem_index < 0) || (SDL_SubsystemRefCount[subsystem_index] < 255));
150+
return ((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] == 0)) ? SDL_TRUE : SDL_FALSE;
150151
}
151152

152153
/* Private helper to check if a system needs to be quit. */
153154
static SDL_bool
154155
SDL_PrivateShouldQuitSubsystem(Uint32 subsystem) {
155-
int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
156-
if (subsystem_index >= 0 && SDL_SubsystemRefCount[subsystem_index] == 0) {
157-
return SDL_FALSE;
156+
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
157+
if ((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] == 0)) {
158+
return SDL_FALSE;
158159
}
159160

160161
/* If we're in SDL_Quit, we shut down every subsystem, even if refcount
161162
* isn't zero.
162163
*/
163-
return ((subsystem_index >= 0 && SDL_SubsystemRefCount[subsystem_index] == 1) || SDL_bInMainQuit) ? SDL_TRUE : SDL_FALSE;
164+
return (((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] == 1)) || SDL_bInMainQuit) ? SDL_TRUE : SDL_FALSE;
164165
}
165166

166167
void

src/joystick/hidapi/SDL_hidapi_shield.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,9 @@ HIDAPI_DriverShield_SendCommand(SDL_HIDAPI_Device *device, Uint8 cmd, const void
169169
}
170170

171171
/* Zero unused data in the payload */
172-
if (size != sizeof(cmd_pkt.payload))
172+
if (size != sizeof(cmd_pkt.payload)) {
173173
SDL_memset(&cmd_pkt.payload[size], 0, sizeof(cmd_pkt.payload) - size);
174+
}
174175

175176
if (SDL_HIDAPI_SendRumbleAndUnlock(device, (Uint8*)&cmd_pkt, sizeof(cmd_pkt)) != sizeof(cmd_pkt)) {
176177
return SDL_SetError("Couldn't send command packet");

src/video/SDL_yuv.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -603,8 +603,10 @@ SDL_ConvertPixels_ARGB8888_to_YUV(int width, int height, const void *src, int sr
603603

604604
if (GetYUVPlanes(width, height, dst_format, dst, dst_pitch,
605605
(const Uint8 **)&plane_y, (const Uint8 **)&plane_u, (const Uint8 **)&plane_v,
606-
&y_stride, &uv_stride) != 0)
606+
&y_stride, &uv_stride) != 0) {
607607
return -1;
608+
}
609+
608610
plane_interleaved_uv = (plane_y + height * y_stride);
609611
y_skip = (y_stride - width);
610612

src/video/windows/SDL_windowskeyboard.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,7 @@ IME_Init(SDL_VideoData *videodata, HWND hwnd)
398398
if (SUCCEEDED(WIN_CoInitialize())) {
399399
videodata->ime_com_initialized = SDL_TRUE;
400400
hResult = CoCreateInstance(&CLSID_TF_ThreadMgr, NULL, CLSCTX_INPROC_SERVER, &IID_ITfThreadMgr, (LPVOID *)&videodata->ime_threadmgr);
401-
if (hResult != S_OK)
402-
{
401+
if (hResult != S_OK) {
403402
videodata->ime_available = SDL_FALSE;
404403
SDL_SetError("CoCreateInstance() failed, HRESULT is %08X", (unsigned int)hResult);
405404
return;

src/video/windows/SDL_windowswindow.c

+13-8
Original file line numberDiff line numberDiff line change
@@ -739,18 +739,22 @@ WIN_GetWindowBordersSize(_THIS, SDL_Window * window, int *top, int *left, int *b
739739

740740
/* rcClient stores the size of the inner window, while rcWindow stores the outer size relative to the top-left
741741
* screen position; so the top/left values of rcClient are always {0,0} and bottom/right are {height,width} */
742-
if (!GetClientRect(hwnd, &rcClient))
743-
SDL_SetError("GetClientRect() failed, error %08X", (unsigned int)GetLastError());
744-
if (!GetWindowRect(hwnd, &rcWindow))
745-
SDL_SetError("GetWindowRect() failed, error %08X", (unsigned int)GetLastError());
742+
if (!GetClientRect(hwnd, &rcClient)) {
743+
return SDL_SetError("GetClientRect() failed, error %08X", (unsigned int)GetLastError());
744+
}
745+
746+
if (!GetWindowRect(hwnd, &rcWindow)) {
747+
return SDL_SetError("GetWindowRect() failed, error %08X", (unsigned int)GetLastError());
748+
}
746749

747750
/* convert the top/left values to make them relative to
748751
* the window; they will end up being slightly negative */
749752
ptDiff.y = rcWindow.top;
750753
ptDiff.x = rcWindow.left;
751754

752-
if (!ScreenToClient(hwnd, &ptDiff))
753-
SDL_SetError("ScreenToClient() failed, error %08X", (unsigned int)GetLastError());
755+
if (!ScreenToClient(hwnd, &ptDiff)) {
756+
return SDL_SetError("ScreenToClient() failed, error %08X", (unsigned int)GetLastError());
757+
}
754758

755759
rcWindow.top = ptDiff.y;
756760
rcWindow.left = ptDiff.x;
@@ -760,8 +764,9 @@ WIN_GetWindowBordersSize(_THIS, SDL_Window * window, int *top, int *left, int *b
760764
ptDiff.y = rcWindow.bottom;
761765
ptDiff.x = rcWindow.right;
762766

763-
if (!ScreenToClient(hwnd, &ptDiff))
764-
SDL_SetError("ScreenToClient() failed, error %08X", (unsigned int)GetLastError());
767+
if (!ScreenToClient(hwnd, &ptDiff)) {
768+
return SDL_SetError("ScreenToClient() failed, error %08X", (unsigned int)GetLastError());
769+
}
765770

766771
rcWindow.bottom = ptDiff.y;
767772
rcWindow.right = ptDiff.x;

0 commit comments

Comments
 (0)