From c6443d86c92e962683a1efe5f123a144988875b5 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Thu, 9 Mar 2023 15:10:00 -0800
Subject: [PATCH] Code style: changed "sizeof foo" to "sizeof(foo)" (thanks
@sezero!)
---
src/audio/SDL_audio.c | 2 +-
src/audio/SDL_wave.c | 2 +-
src/audio/aaudio/SDL_aaudio.c | 2 +-
src/audio/alsa/SDL_alsa_audio.c | 3 +-
src/audio/android/SDL_androidaudio.c | 2 +-
src/audio/coreaudio/SDL_coreaudio.m | 3 +-
src/audio/directsound/SDL_directsound.c | 3 +-
src/audio/dsp/SDL_dspaudio.c | 3 +-
src/audio/emscripten/SDL_emscriptenaudio.c | 5 +-
src/audio/jack/SDL_jackaudio.c | 3 +-
src/audio/n3ds/SDL_n3dsaudio.c | 2 +-
src/audio/netbsd/SDL_netbsdaudio.c | 3 +-
src/audio/openslES/SDL_openslES.c | 2 +-
src/audio/pulseaudio/SDL_pulseaudio.c | 3 +-
src/audio/wasapi/SDL_wasapi.c | 4 +-
src/core/linux/SDL_evdev.c | 2 +-
src/core/linux/SDL_fcitx.c | 4 +-
src/core/linux/SDL_ibus.c | 6 +-
src/core/windows/SDL_windows.c | 2 +-
src/file/SDL_rwops.c | 2 +-
src/haptic/SDL_haptic.c | 6 +-
src/haptic/windows/SDL_xinputhaptic.c | 4 +-
src/joystick/SDL_gamepad.c | 8 +-
src/joystick/bsd/SDL_bsdjoystick.c | 2 +-
src/joystick/haiku/SDL_haikujoystick.cc | 4 +-
src/joystick/hidapi/SDL_hidapi_ps3.c | 2 +-
src/joystick/hidapi/SDL_hidapi_ps4.c | 10 +--
src/joystick/hidapi/SDL_hidapi_ps5.c | 6 +-
src/joystick/hidapi/SDL_hidapi_switch.c | 2 +-
src/joystick/linux/SDL_sysjoystick.c | 4 +-
src/joystick/windows/SDL_dinputjoystick.c | 14 ++--
.../windows/SDL_windows_gaming_input.c | 4 +-
src/joystick/windows/SDL_xinputjoystick.c | 22 ++---
src/sensor/n3ds/SDL_n3dssensor.c | 4 +-
src/test/SDL_test_common.c | 84 +++++++++----------
src/test/SDL_test_font.c | 2 +-
src/test/SDL_test_harness.c | 4 +-
src/test/SDL_test_log.c | 2 +-
src/test/SDL_test_memory.c | 10 +--
src/video/dummy/SDL_nullframebuffer.c | 2 +-
src/video/kmsdrm/SDL_kmsdrmvideo.c | 4 +-
.../offscreen/SDL_offscreenframebuffer.c | 3 +-
src/video/wayland/SDL_waylandevents.c | 25 +++---
src/video/wayland/SDL_waylandwindow.c | 2 +-
src/video/x11/SDL_x11keyboard.c | 2 +-
test/checkkeys.c | 2 +-
test/checkkeysthreads.c | 2 +-
test/gamepadmap.c | 12 +--
test/testatomic.c | 12 +--
test/testdisplayinfo.c | 2 +-
test/testlock.c | 4 +-
test/testoffscreen.c | 5 +-
test/testsem.c | 12 +--
test/testsensor.c | 2 +-
test/testwm.c | 6 +-
test/testyuv.c | 2 +-
test/torturethread.c | 4 +-
57 files changed, 176 insertions(+), 179 deletions(-)
diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c
index 8caa26b762a6..56dc2e89641c 100644
--- a/src/audio/SDL_audio.c
+++ b/src/audio/SDL_audio.c
@@ -1474,7 +1474,7 @@ static SDL_AudioDeviceID open_audio_device(const char *devname, int iscapture,
const size_t stacksize = is_internal_thread ? 64 * 1024 : 0;
char threadname[64];
- (void)SDL_snprintf(threadname, sizeof threadname, "SDLAudio%c%" SDL_PRIu32, (iscapture) ? 'C' : 'P', device->id);
+ (void)SDL_snprintf(threadname, sizeof(threadname), "SDLAudio%c%" SDL_PRIu32, (iscapture) ? 'C' : 'P', device->id);
device->thread = SDL_CreateThreadInternal(iscapture ? SDL_CaptureAudio : SDL_RunAudio, threadname, stacksize, device);
if (device->thread == NULL) {
diff --git a/src/audio/SDL_wave.c b/src/audio/SDL_wave.c
index 8d8b533ccb0c..9b2e8b79ef85 100644
--- a/src/audio/SDL_wave.c
+++ b/src/audio/SDL_wave.c
@@ -1806,7 +1806,7 @@ static int WaveLoad(SDL_RWops *src, WaveFile *file, SDL_AudioSpec *spec, Uint8 *
if (RIFFchunk.fourcc == RIFF) {
Uint32 formtype;
/* Read the form type. "WAVE" expected. */
- if (SDL_RWread(src, &formtype, sizeof(Uint32)) != sizeof (Uint32)) {
+ if (SDL_RWread(src, &formtype, sizeof(Uint32)) != sizeof(Uint32)) {
return SDL_SetError("Could not read RIFF form type");
} else if (SDL_SwapLE32(formtype) != WAVE) {
return SDL_SetError("RIFF form type is not WAVE (not a Waveform file)");
diff --git a/src/audio/aaudio/SDL_aaudio.c b/src/audio/aaudio/SDL_aaudio.c
index 312a3cf7eb5f..b078ffda6a8f 100644
--- a/src/audio/aaudio/SDL_aaudio.c
+++ b/src/audio/aaudio/SDL_aaudio.c
@@ -91,7 +91,7 @@ static int aaudio_OpenDevice(_THIS, const char *devname)
audioDevice = this;
}
- this->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, (sizeof *this->hidden));
+ this->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*this->hidden));
if (this->hidden == NULL) {
return SDL_OutOfMemory();
}
diff --git a/src/audio/alsa/SDL_alsa_audio.c b/src/audio/alsa/SDL_alsa_audio.c
index 6ff9f41cde86..d09774e09960 100644
--- a/src/audio/alsa/SDL_alsa_audio.c
+++ b/src/audio/alsa/SDL_alsa_audio.c
@@ -535,8 +535,7 @@ static int ALSA_OpenDevice(_THIS, const char *devname)
#endif
/* Initialize all variables that we clean on shutdown */
- this->hidden = (struct SDL_PrivateAudioData *)
- SDL_malloc((sizeof *this->hidden));
+ this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden));
if (this->hidden == NULL) {
return SDL_OutOfMemory();
}
diff --git a/src/audio/android/SDL_androidaudio.c b/src/audio/android/SDL_androidaudio.c
index be2e81ba89a0..60e5fe147f55 100644
--- a/src/audio/android/SDL_androidaudio.c
+++ b/src/audio/android/SDL_androidaudio.c
@@ -49,7 +49,7 @@ static int ANDROIDAUDIO_OpenDevice(_THIS, const char *devname)
audioDevice = this;
}
- this->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, (sizeof *this->hidden));
+ this->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*this->hidden));
if (this->hidden == NULL) {
return SDL_OutOfMemory();
}
diff --git a/src/audio/coreaudio/SDL_coreaudio.m b/src/audio/coreaudio/SDL_coreaudio.m
index c089a267aec1..936cc235dfb8 100644
--- a/src/audio/coreaudio/SDL_coreaudio.m
+++ b/src/audio/coreaudio/SDL_coreaudio.m
@@ -1013,8 +1013,7 @@ static int COREAUDIO_OpenDevice(_THIS, const char *devname)
SDL_AudioDevice **new_open_devices;
/* Initialize all variables that we clean on shutdown */
- this->hidden = (struct SDL_PrivateAudioData *)
- SDL_malloc((sizeof *this->hidden));
+ this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden));
if (this->hidden == NULL) {
return SDL_OutOfMemory();
}
diff --git a/src/audio/directsound/SDL_directsound.c b/src/audio/directsound/SDL_directsound.c
index 65a467a04177..a50074d88eae 100644
--- a/src/audio/directsound/SDL_directsound.c
+++ b/src/audio/directsound/SDL_directsound.c
@@ -489,8 +489,7 @@ static int DSOUND_OpenDevice(_THIS, const char *devname)
DWORD bufsize;
/* Initialize all variables that we clean on shutdown */
- this->hidden = (struct SDL_PrivateAudioData *)
- SDL_malloc((sizeof *this->hidden));
+ this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden));
if (this->hidden == NULL) {
return SDL_OutOfMemory();
}
diff --git a/src/audio/dsp/SDL_dspaudio.c b/src/audio/dsp/SDL_dspaudio.c
index b2aac5b3962a..4a740e7d87be 100644
--- a/src/audio/dsp/SDL_dspaudio.c
+++ b/src/audio/dsp/SDL_dspaudio.c
@@ -83,8 +83,7 @@ static int DSP_OpenDevice(_THIS, const char *devname)
}
/* Initialize all variables that we clean on shutdown */
- this->hidden = (struct SDL_PrivateAudioData *)
- SDL_malloc((sizeof *this->hidden));
+ this->hidden = (struct SDL_PrivateAudioData *) SDL_malloc(sizeof(*this->hidden));
if (this->hidden == NULL) {
return SDL_OutOfMemory();
}
diff --git a/src/audio/emscripten/SDL_emscriptenaudio.c b/src/audio/emscripten/SDL_emscriptenaudio.c
index 552e69208898..05d17ef1f6d8 100644
--- a/src/audio/emscripten/SDL_emscriptenaudio.c
+++ b/src/audio/emscripten/SDL_emscriptenaudio.c
@@ -124,7 +124,7 @@ static void HandleCaptureProcess(_THIS)
}
}
}
- }, this->work_buffer, (this->spec.size / sizeof (float)) / this->spec.channels);
+ }, this->work_buffer, (this->spec.size / sizeof(float)) / this->spec.channels);
/* *INDENT-ON* */ /* clang-format on */
/* okay, we've got an interleaved float32 array in C now. */
@@ -253,8 +253,7 @@ static int EMSCRIPTENAUDIO_OpenDevice(_THIS, const char *devname)
/* Initialize all variables that we clean on shutdown */
#if 0 /* !!! FIXME: currently not used. Can we move some stuff off the SDL3 namespace? --ryan. */
- this->hidden = (struct SDL_PrivateAudioData *)
- SDL_malloc((sizeof *this->hidden));
+ this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden));
if (this->hidden == NULL) {
return SDL_OutOfMemory();
}
diff --git a/src/audio/jack/SDL_jackaudio.c b/src/audio/jack/SDL_jackaudio.c
index 93af465ea5d5..2fdec832f024 100644
--- a/src/audio/jack/SDL_jackaudio.c
+++ b/src/audio/jack/SDL_jackaudio.c
@@ -129,6 +129,7 @@ static int load_jack_syms(void)
SDL_JACK_SYM(jack_port_type);
SDL_JACK_SYM(jack_connect);
SDL_JACK_SYM(jack_set_process_callback);
+
return 0;
}
@@ -298,7 +299,7 @@ static int JACK_OpenDevice(_THIS, const char *devname)
}
/* Filter out non-audio ports */
- audio_ports = SDL_calloc(ports, sizeof *audio_ports);
+ audio_ports = SDL_calloc(ports, sizeof(*audio_ports));
for (i = 0; i < ports; i++) {
const jack_port_t *dport = JACK_jack_port_by_name(client, devports[i]);
const char *type = JACK_jack_port_type(dport);
diff --git a/src/audio/n3ds/SDL_n3dsaudio.c b/src/audio/n3ds/SDL_n3dsaudio.c
index d22689253f7b..d03721583af3 100644
--- a/src/audio/n3ds/SDL_n3dsaudio.c
+++ b/src/audio/n3ds/SDL_n3dsaudio.c
@@ -93,7 +93,7 @@ static int N3DSAUDIO_OpenDevice(_THIS, const char *devname)
Result ndsp_init_res;
Uint8 *data_vaddr;
float mix[12];
- this->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof *this->hidden);
+ this->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*this->hidden));
if (this->hidden == NULL) {
return SDL_OutOfMemory();
diff --git a/src/audio/netbsd/SDL_netbsdaudio.c b/src/audio/netbsd/SDL_netbsdaudio.c
index 0190d47576b9..18cf9e44804a 100644
--- a/src/audio/netbsd/SDL_netbsdaudio.c
+++ b/src/audio/netbsd/SDL_netbsdaudio.c
@@ -208,8 +208,7 @@ static int NETBSDAUDIO_OpenDevice(_THIS, const char *devname)
}
/* Initialize all variables that we clean on shutdown */
- this->hidden = (struct SDL_PrivateAudioData *)
- SDL_malloc((sizeof *this->hidden));
+ this->hidden = (struct SDL_PrivateAudioData *) SDL_malloc(sizeof(*this->hidden));
if (this->hidden == NULL) {
return SDL_OutOfMemory();
}
diff --git a/src/audio/openslES/SDL_openslES.c b/src/audio/openslES/SDL_openslES.c
index a367fe964bc7..6b447081f57d 100644
--- a/src/audio/openslES/SDL_openslES.c
+++ b/src/audio/openslES/SDL_openslES.c
@@ -589,7 +589,7 @@ static int openslES_CreatePCMPlayer(_THIS)
static int openslES_OpenDevice(_THIS, const char *devname)
{
- this->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, (sizeof *this->hidden));
+ this->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*this->hidden));
if (this->hidden == NULL) {
return SDL_OutOfMemory();
}
diff --git a/src/audio/pulseaudio/SDL_pulseaudio.c b/src/audio/pulseaudio/SDL_pulseaudio.c
index 8c218ba7638b..c152564809f6 100644
--- a/src/audio/pulseaudio/SDL_pulseaudio.c
+++ b/src/audio/pulseaudio/SDL_pulseaudio.c
@@ -529,8 +529,7 @@ static int PULSEAUDIO_OpenDevice(_THIS, const char *devname)
int rc = 0;
/* Initialize all variables that we clean on shutdown */
- h = this->hidden = (struct SDL_PrivateAudioData *)
- SDL_malloc((sizeof *this->hidden));
+ h = this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden));
if (this->hidden == NULL) {
return SDL_OutOfMemory();
}
diff --git a/src/audio/wasapi/SDL_wasapi.c b/src/audio/wasapi/SDL_wasapi.c
index e8a9b5ade5dd..ac95d2295507 100644
--- a/src/audio/wasapi/SDL_wasapi.c
+++ b/src/audio/wasapi/SDL_wasapi.c
@@ -47,6 +47,7 @@
static const IID SDL_IID_IAudioRenderClient = { 0xf294acfc, 0x3146, 0x4483, { 0xa7, 0xbf, 0xad, 0xdc, 0xa7, 0xc2, 0x60, 0xe2 } };
static const IID SDL_IID_IAudioCaptureClient = { 0xc8adbd64, 0xe71e, 0x48a0, { 0xa4, 0xde, 0x18, 0x5c, 0x39, 0x5c, 0xd3, 0x17 } };
+
static void WASAPI_DetectDevices(void)
{
WASAPI_EnumerateEndpoints();
@@ -528,8 +529,7 @@ static int WASAPI_OpenDevice(_THIS, const char *devname)
LPCWSTR devid = (LPCWSTR)this->handle;
/* Initialize all variables that we clean on shutdown */
- this->hidden = (struct SDL_PrivateAudioData *)
- SDL_malloc((sizeof *this->hidden));
+ this->hidden = (struct SDL_PrivateAudioData *) SDL_malloc(sizeof(*this->hidden));
if (this->hidden == NULL) {
return SDL_OutOfMemory();
}
diff --git a/src/core/linux/SDL_evdev.c b/src/core/linux/SDL_evdev.c
index 23a1b53fdd71..4f228063e575 100644
--- a/src/core/linux/SDL_evdev.c
+++ b/src/core/linux/SDL_evdev.c
@@ -287,7 +287,7 @@ void SDL_EVDEV_Poll(void)
mouse = SDL_GetMouse();
for (item = _this->first; item != NULL; item = item->next) {
- while ((len = read(item->fd, events, (sizeof events))) > 0) {
+ while ((len = read(item->fd, events, sizeof(events))) > 0) {
len /= sizeof(events[0]);
for (i = 0; i < len; ++i) {
struct input_event *event = &events[i];
diff --git a/src/core/linux/SDL_fcitx.c b/src/core/linux/SDL_fcitx.c
index 7ce6f02285a3..01bc7266adf5 100644
--- a/src/core/linux/SDL_fcitx.c
+++ b/src/core/linux/SDL_fcitx.c
@@ -62,9 +62,9 @@ static char *GetAppName(void)
int linksize;
#if defined(__LINUX__)
- (void)SDL_snprintf(procfile, sizeof procfile, "/proc/%d/exe", getpid());
+ (void)SDL_snprintf(procfile, sizeof(procfile), "/proc/%d/exe", getpid());
#elif defined(__FREEBSD__)
- (void)SDL_snprintf(procfile, sizeof procfile, "/proc/%d/file", getpid());
+ (void)SDL_snprintf(procfile, sizeof(procfile), "/proc/%d/file", getpid());
#endif
linksize = readlink(procfile, linkfile, sizeof(linkfile) - 1);
if (linksize > 0) {
diff --git a/src/core/linux/SDL_ibus.c b/src/core/linux/SDL_ibus.c
index a9554700539e..7f10a0c1274d 100644
--- a/src/core/linux/SDL_ibus.c
+++ b/src/core/linux/SDL_ibus.c
@@ -405,13 +405,13 @@ static char *IBus_GetDBusAddressFilename(void)
SDL_free(display);
return NULL;
}
- (void)SDL_snprintf(config_dir, sizeof config_dir, "%s/.config", home_env);
+ (void)SDL_snprintf(config_dir, sizeof(config_dir), "%s/.config", home_env);
}
key = dbus->get_local_machine_id();
SDL_memset(file_path, 0, sizeof(file_path));
- (void)SDL_snprintf(file_path, sizeof file_path, "%s/ibus/bus/%s-%s-%s",
+ (void)SDL_snprintf(file_path, sizeof(file_path), "%s/ibus/bus/%s-%s-%s",
config_dir, key, host, disp_num);
dbus->free(key);
SDL_free(display);
@@ -489,7 +489,7 @@ static SDL_bool IBus_SetupConnection(SDL_DBusContext *dbus, const char *addr)
if (result) {
char matchstr[128];
- (void)SDL_snprintf(matchstr, sizeof matchstr, "type='signal',interface='%s'", ibus_input_interface);
+ (void)SDL_snprintf(matchstr, sizeof(matchstr), "type='signal',interface='%s'", ibus_input_interface);
SDL_free(input_ctx_path);
input_ctx_path = SDL_strdup(path);
SDL_AddHintCallback(SDL_HINT_IME_INTERNAL_EDITING, IBus_SetCapabilities, NULL);
diff --git a/src/core/windows/SDL_windows.c b/src/core/windows/SDL_windows.c
index 3945a9e24222..137721b27958 100644
--- a/src/core/windows/SDL_windows.c
+++ b/src/core/windows/SDL_windows.c
@@ -266,7 +266,7 @@ WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid)
}
ptr = (const unsigned char *)guid;
- (void)SDL_snprintf(keystr, sizeof keystr,
+ (void)SDL_snprintf(keystr, sizeof(keystr),
"System\\CurrentControlSet\\Control\\MediaCategories\\{%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
ptr[3], ptr[2], ptr[1], ptr[0], ptr[5], ptr[4], ptr[7], ptr[6],
ptr[8], ptr[9], ptr[10], ptr[11], ptr[12], ptr[13], ptr[14], ptr[15]);
diff --git a/src/file/SDL_rwops.c b/src/file/SDL_rwops.c
index ff58f51f141e..e26c07fbbdda 100644
--- a/src/file/SDL_rwops.c
+++ b/src/file/SDL_rwops.c
@@ -654,7 +654,7 @@ SDL_CreateRW(void)
{
SDL_RWops *area;
- area = (SDL_RWops *)SDL_malloc(sizeof *area);
+ area = (SDL_RWops *)SDL_malloc(sizeof(*area));
if (area == NULL) {
SDL_OutOfMemory();
} else {
diff --git a/src/haptic/SDL_haptic.c b/src/haptic/SDL_haptic.c
index e3310c7d2162..72dc78899b00 100644
--- a/src/haptic/SDL_haptic.c
+++ b/src/haptic/SDL_haptic.c
@@ -125,14 +125,14 @@ SDL_HapticOpen(int device_index)
}
/* Create the haptic device */
- haptic = (SDL_Haptic *)SDL_malloc((sizeof *haptic));
+ haptic = (SDL_Haptic *)SDL_malloc(sizeof(*haptic));
if (haptic == NULL) {
SDL_OutOfMemory();
return NULL;
}
/* Initialize the haptic device */
- SDL_memset(haptic, 0, (sizeof *haptic));
+ SDL_memset(haptic, 0, sizeof(*haptic));
haptic->rumble_id = -1;
haptic->index = device_index;
if (SDL_SYS_HapticOpen(haptic) < 0) {
@@ -299,7 +299,7 @@ SDL_HapticOpenFromJoystick(SDL_Joystick *joystick)
}
/* Create the haptic device */
- haptic = (SDL_Haptic *)SDL_malloc((sizeof *haptic));
+ haptic = (SDL_Haptic *)SDL_malloc(sizeof(*haptic));
if (haptic == NULL) {
SDL_OutOfMemory();
SDL_UnlockJoysticks();
diff --git a/src/haptic/windows/SDL_xinputhaptic.c b/src/haptic/windows/SDL_xinputhaptic.c
index 8156827fb6f0..d612b67470af 100644
--- a/src/haptic/windows/SDL_xinputhaptic.c
+++ b/src/haptic/windows/SDL_xinputhaptic.c
@@ -88,7 +88,7 @@ int SDL_XINPUT_HapticMaybeAddDevice(const DWORD dwUserid)
/* !!! FIXME: I'm not bothering to query for a real name right now (can we even?) */
{
char buf[64];
- (void)SDL_snprintf(buf, sizeof buf, "XInput Controller #%u", userid + 1);
+ (void)SDL_snprintf(buf, sizeof(buf), "XInput Controller #%u", userid + 1);
item->name = SDL_strdup(buf);
}
@@ -199,7 +199,7 @@ static int SDL_XINPUT_HapticOpenFromUserIndex(SDL_Haptic *haptic, const Uint8 us
return SDL_SetError("Couldn't create XInput haptic mutex");
}
- (void)SDL_snprintf(threadName, sizeof threadName, "SDLXInputDev%u", userid);
+ (void)SDL_snprintf(threadName, sizeof(threadName), "SDLXInputDev%d", userid);
haptic->hwdata->thread = SDL_CreateThreadInternal(SDL_RunXInputHaptic, threadName, 64 * 1024, haptic->hwdata);
if (haptic->hwdata->thread == NULL) {
diff --git a/src/joystick/SDL_gamepad.c b/src/joystick/SDL_gamepad.c
index a732e880b7a0..5c50e38fbd78 100644
--- a/src/joystick/SDL_gamepad.c
+++ b/src/joystick/SDL_gamepad.c
@@ -1376,13 +1376,13 @@ static void SDL_PrivateAppendToMappingString(char *mapping_string,
SDL_strlcat(mapping_string, ":", mapping_string_len);
switch (mapping->kind) {
case EMappingKind_Button:
- (void)SDL_snprintf(buffer, sizeof buffer, "b%i", mapping->target);
+ (void)SDL_snprintf(buffer, sizeof(buffer), "b%i", mapping->target);
break;
case EMappingKind_Axis:
- (void)SDL_snprintf(buffer, sizeof buffer, "a%i", mapping->target);
+ (void)SDL_snprintf(buffer, sizeof(buffer), "a%i", mapping->target);
break;
case EMappingKind_Hat:
- (void)SDL_snprintf(buffer, sizeof buffer, "h%i.%i", mapping->target >> 4, mapping->target & 0x0F);
+ (void)SDL_snprintf(buffer, sizeof(buffer), "h%i.%i", mapping->target >> 4, mapping->target & 0x0F);
break;
default:
SDL_assert(SDL_FALSE);
@@ -1410,7 +1410,7 @@ static GamepadMapping_t *SDL_PrivateGenerateAutomaticGamepadMapping(const char *
}
}
}
- (void)SDL_snprintf(mapping, sizeof mapping, "none,%s,", name_string);
+ (void)SDL_snprintf(mapping, sizeof(mapping), "none,%s,", name_string);
SDL_PrivateAppendToMappingString(mapping, sizeof(mapping), "a", &raw_map->a);
SDL_PrivateAppendToMappingString(mapping, sizeof(mapping), "b", &raw_map->b);
SDL_PrivateAppendToMappingString(mapping, sizeof(mapping), "x", &raw_map->x);
diff --git a/src/joystick/bsd/SDL_bsdjoystick.c b/src/joystick/bsd/SDL_bsdjoystick.c
index b2f34edeaad2..bd08183a7675 100644
--- a/src/joystick/bsd/SDL_bsdjoystick.c
+++ b/src/joystick/bsd/SDL_bsdjoystick.c
@@ -647,7 +647,7 @@ static void BSD_JoystickUpdate(SDL_Joystick *joy)
static int x, y, xmin = 0xffff, ymin = 0xffff, xmax = 0, ymax = 0;
if (joy->hwdata->type == BSDJOY_JOY) {
- while (read(joy->hwdata->fd, &gameport, sizeof gameport) == sizeof gameport) {
+ while (read(joy->hwdata->fd, &gameport, sizeof(gameport)) == sizeof(gameport)) {
if (SDL_abs(x - gameport.x) > 8) {
x = gameport.x;
if (x < xmin) {
diff --git a/src/joystick/haiku/SDL_haikujoystick.cc b/src/joystick/haiku/SDL_haikujoystick.cc
index f8858621d1ce..49e4d69fefbd 100644
--- a/src/joystick/haiku/SDL_haikujoystick.cc
+++ b/src/joystick/haiku/SDL_haikujoystick.cc
@@ -65,8 +65,8 @@ extern "C"
/* Search for attached joysticks */
nports = joystick.CountDevices();
numjoysticks = 0;
- SDL_memset(SDL_joyport, 0, (sizeof SDL_joyport));
- SDL_memset(SDL_joyname, 0, (sizeof SDL_joyname));
+ SDL_memset(SDL_joyport, 0, sizeof(SDL_joyport));
+ SDL_memset(SDL_joyname, 0, sizeof(SDL_joyname));
for (i = 0; (numjoysticks < MAX_JOYSTICKS) && (i < nports); ++i) {
if (joystick.GetDeviceName(i, name) == B_OK) {
if (joystick.Open(name) != B_ERROR) {
diff --git a/src/joystick/hidapi/SDL_hidapi_ps3.c b/src/joystick/hidapi/SDL_hidapi_ps3.c
index e26596ccd739..882f9e4e41c6 100644
--- a/src/joystick/hidapi/SDL_hidapi_ps3.c
+++ b/src/joystick/hidapi/SDL_hidapi_ps3.c
@@ -583,7 +583,7 @@ static SDL_bool HIDAPI_DriverPS3ThirdParty_IsSupportedDevice(SDL_HIDAPI_Device *
if (HIDAPI_SupportsPlaystationDetection(vendor_id, product_id)) {
if (device && device->dev) {
- size = ReadFeatureReport(device->dev, 0x03, data, sizeof data);
+ size = ReadFeatureReport(device->dev, 0x03, data, sizeof(data));
if (size == 8 && data[2] == 0x26) {
/* Supported third party controller */
return SDL_TRUE;
diff --git a/src/joystick/hidapi/SDL_hidapi_ps4.c b/src/joystick/hidapi/SDL_hidapi_ps4.c
index 03f60c279f13..bef553689b52 100644
--- a/src/joystick/hidapi/SDL_hidapi_ps4.c
+++ b/src/joystick/hidapi/SDL_hidapi_ps4.c
@@ -185,7 +185,7 @@ static SDL_bool HIDAPI_DriverPS4_IsSupportedDevice(SDL_HIDAPI_Device *device, co
if (HIDAPI_SupportsPlaystationDetection(vendor_id, product_id)) {
if (device && device->dev) {
- size = ReadFeatureReport(device->dev, k_ePS4FeatureReportIdCapabilities, data, sizeof data);
+ size = ReadFeatureReport(device->dev, k_ePS4FeatureReportIdCapabilities, data, sizeof(data));
if (size == 48 && data[2] == 0x27) {
/* Supported third party controller */
return SDL_TRUE;
@@ -264,7 +264,7 @@ static SDL_bool HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device)
if (ctx->is_dongle) {
size = ReadFeatureReport(device->dev, k_ePS4FeatureReportIdSerialNumber, data, sizeof(data));
if (size >= 7 && (data[1] || data[2] || data[3] || data[4] || data[5] || data[6])) {
- (void)SDL_snprintf(serial, sizeof serial, "%.2x-%.2x-%.2x-%.2x-%.2x-%.2x",
+ (void)SDL_snprintf(serial, sizeof(serial), "%.2x-%.2x-%.2x-%.2x-%.2x-%.2x",
data[6], data[5], data[4], data[3], data[2], data[1]);
}
device->is_bluetooth = SDL_FALSE;
@@ -277,7 +277,7 @@ static SDL_bool HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device)
/* This will fail if we're on Bluetooth */
size = ReadFeatureReport(device->dev, k_ePS4FeatureReportIdSerialNumber, data, sizeof(data));
if (size >= 7 && (data[1] || data[2] || data[3] || data[4] || data[5] || data[6])) {
- (void)SDL_snprintf(serial, sizeof serial, "%.2x-%.2x-%.2x-%.2x-%.2x-%.2x",
+ (void)SDL_snprintf(serial, sizeof(serial), "%.2x-%.2x-%.2x-%.2x-%.2x-%.2x",
data[6], data[5], data[4], data[3], data[2], data[1]);
device->is_bluetooth = SDL_FALSE;
ctx->enhanced_mode = SDL_TRUE;
@@ -308,7 +308,7 @@ static SDL_bool HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device)
SDL_Log("PS4 dongle = %s, bluetooth = %s\n", ctx->is_dongle ? "TRUE" : "FALSE", device->is_bluetooth ? "TRUE" : "FALSE");
#endif
- size = ReadFeatureReport(device->dev, k_ePS4FeatureReportIdCapabilities, data, sizeof data);
+ size = ReadFeatureReport(device->dev, k_ePS4FeatureReportIdCapabilities, data, sizeof(data));
/* Get the device capabilities */
if (size == 48 && data[2] == 0x27) {
Uint8 capabilities = data[4];
@@ -1121,7 +1121,7 @@ static SDL_bool HIDAPI_DriverPS4_UpdateDevice(SDL_HIDAPI_Device *device)
char serial[18];
size = ReadFeatureReport(device->dev, k_ePS4FeatureReportIdSerialNumber, data, sizeof(data));
if (size >= 7 && (data[1] || data[2] || data[3] || data[4] || data[5] || data[6])) {
- (void)SDL_snprintf(serial, sizeof serial, "%.2x-%.2x-%.2x-%.2x-%.2x-%.2x",
+ (void)SDL_snprintf(serial, sizeof(serial), "%.2x-%.2x-%.2x-%.2x-%.2x-%.2x",
data[6], data[5], data[4], data[3], data[2], data[1]);
HIDAPI_SetDeviceSerial(device, serial);
}
diff --git a/src/joystick/hidapi/SDL_hidapi_ps5.c b/src/joystick/hidapi/SDL_hidapi_ps5.c
index 56c92c669d5f..5011e488f77c 100644
--- a/src/joystick/hidapi/SDL_hidapi_ps5.c
+++ b/src/joystick/hidapi/SDL_hidapi_ps5.c
@@ -280,7 +280,7 @@ static SDL_bool HIDAPI_DriverPS5_IsSupportedDevice(SDL_HIDAPI_Device *device, co
if (HIDAPI_SupportsPlaystationDetection(vendor_id, product_id)) {
if (device && device->dev) {
- size = ReadFeatureReport(device->dev, k_EPS5FeatureReportIdCapabilities, data, sizeof data);
+ size = ReadFeatureReport(device->dev, k_EPS5FeatureReportIdCapabilities, data, sizeof(data));
if (size == 48 && data[2] == 0x28) {
/* Supported third party controller */
return SDL_TRUE;
@@ -405,7 +405,7 @@ static SDL_bool HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device)
This will also enable enhanced reports over Bluetooth
*/
if (ReadFeatureReport(device->dev, k_EPS5FeatureReportIdSerialNumber, data, sizeof(data)) >= 7) {
- (void)SDL_snprintf(serial, sizeof serial, "%.2x-%.2x-%.2x-%.2x-%.2x-%.2x",
+ (void)SDL_snprintf(serial, sizeof(serial), "%.2x-%.2x-%.2x-%.2x-%.2x-%.2x",
data[6], data[5], data[4], data[3], data[2], data[1]);
}
@@ -417,7 +417,7 @@ static SDL_bool HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device)
}
}
- size = ReadFeatureReport(device->dev, k_EPS5FeatureReportIdCapabilities, data, sizeof data);
+ size = ReadFeatureReport(device->dev, k_EPS5FeatureReportIdCapabilities, data, sizeof(data));
/* Get the device capabilities */
if (device->vendor_id == USB_VENDOR_SONY) {
ctx->sensors_supported = SDL_TRUE;
diff --git a/src/joystick/hidapi/SDL_hidapi_switch.c b/src/joystick/hidapi/SDL_hidapi_switch.c
index 1111dd630c3d..e03c3d66eab5 100644
--- a/src/joystick/hidapi/SDL_hidapi_switch.c
+++ b/src/joystick/hidapi/SDL_hidapi_switch.c
@@ -1214,7 +1214,7 @@ static void UpdateDeviceIdentity(SDL_HIDAPI_Device *device)
}
device->guid.data[15] = ctx->m_eControllerType;
- (void)SDL_snprintf(serial, sizeof serial, "%.2x-%.2x-%.2x-%.2x-%.2x-%.2x",
+ (void)SDL_snprintf(serial, sizeof(serial), "%.2x-%.2x-%.2x-%.2x-%.2x-%.2x",
ctx->m_rgucMACAddress[0],
ctx->m_rgucMACAddress[1],
ctx->m_rgucMACAddress[2],
diff --git a/src/joystick/linux/SDL_sysjoystick.c b/src/joystick/linux/SDL_sysjoystick.c
index bc282b70bfd8..5f07bdf41a5e 100644
--- a/src/joystick/linux/SDL_sysjoystick.c
+++ b/src/joystick/linux/SDL_sysjoystick.c
@@ -1414,7 +1414,7 @@ static void HandleInputEvents(SDL_Joystick *joystick)
joystick->hwdata->fresh = SDL_FALSE;
}
- while ((len = read(joystick->hwdata->fd, events, (sizeof events))) > 0) {
+ while ((len = read(joystick->hwdata->fd, events, sizeof(events))) > 0) {
len /= sizeof(events[0]);
for (i = 0; i < len; ++i) {
struct input_event *event = &events[i];
@@ -1495,7 +1495,7 @@ static void HandleClassicEvents(SDL_Joystick *joystick)
SDL_AssertJoysticksLocked();
joystick->hwdata->fresh = SDL_FALSE;
- while ((len = read(joystick->hwdata->fd, events, (sizeof events))) > 0) {
+ while ((len = read(joystick->hwdata->fd, events, sizeof(events))) > 0) {
len /= sizeof(events[0]);
for (i = 0; i < len; ++i) {
switch (events[i].type) {
diff --git a/src/joystick/windows/SDL_dinputjoystick.c b/src/joystick/windows/SDL_dinputjoystick.c
index 69c83bce9350..1dc26b6012ef 100644
--- a/src/joystick/windows/SDL_dinputjoystick.c
+++ b/src/joystick/windows/SDL_dinputjoystick.c
@@ -621,19 +621,19 @@ static BOOL CALLBACK EnumDevObjectsCallback(LPCDIDEVICEOBJECTINSTANCE pDeviceObj
in->type = AXIS;
in->num = joystick->naxes;
- if (SDL_memcmp(&pDeviceObject->guidType, &GUID_XAxis, sizeof pDeviceObject->guidType) == 0) {
+ if (SDL_memcmp(&pDeviceObject->guidType, &GUID_XAxis, sizeof(pDeviceObject->guidType)) == 0) {
in->ofs = DIJOFS_X;
- } else if (SDL_memcmp(&pDeviceObject->guidType, &GUID_YAxis, sizeof pDeviceObject->guidType) == 0) {
+ } else if (SDL_memcmp(&pDeviceObject->guidType, &GUID_YAxis, sizeof(pDeviceObject->guidType)) == 0) {
in->ofs = DIJOFS_Y;
- } else if (SDL_memcmp(&pDeviceObject->guidType, &GUID_ZAxis, sizeof pDeviceObject->guidType) == 0) {
+ } else if (SDL_memcmp(&pDeviceObject->guidType, &GUID_ZAxis, sizeof(pDeviceObject->guidType)) == 0) {
(Patch may be truncated, please check the link at the top of this post.)