diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c index 8caa26b76..56dc2e896 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 8d8b533cc..9b2e8b79e 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 312a3cf7e..b078ffda6 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 6ff9f41cd..d09774e09 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 be2e81ba8..60e5fe147 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 c089a267a..936cc235d 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 65a467a04..a50074d88 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 b2aac5b39..4a740e7d8 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 552e69208..05d17ef1f 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 93af465ea..2fdec832f 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 d22689253..d03721583 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 0190d4757..18cf9e448 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 a367fe964..6b447081f 100644 --- a/src/audio/openslES/SDL_openslES.c +++ b/src/audio/openslES/SDL_openslES.c @@ -589,7 +589,7 @@ failed: 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 8c218ba76..c15256480 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 e8a9b5ade..ac95d2295 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 23a1b53fd..4f228063e 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 7ce6f0228..01bc7266a 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 a95547005..7f10a0c12 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 3945a9e24..137721b27 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 ff58f51f1..e26c07fbb 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 e3310c7d2..72dc78899 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 8156827fb..d612b6747 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 a732e880b..5c50e38fb 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 b2f34edea..bd08183a7 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 f8858621d..49e4d69fe 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 e26596ccd..882f9e4e4 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 03f60c279..bef553689 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 56c92c669..5011e488f 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 1111dd630..e03c3d66e 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 bc282b70b..5f07bdf41 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 69c83bce9..1dc26b601 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) { in->ofs = DIJOFS_Z; - } else if (SDL_memcmp(&pDeviceObject->guidType, &GUID_RxAxis, sizeof pDeviceObject->guidType) == 0) { + } else if (SDL_memcmp(&pDeviceObject->guidType, &GUID_RxAxis, sizeof(pDeviceObject->guidType)) == 0) { in->ofs = DIJOFS_RX; - } else if (SDL_memcmp(&pDeviceObject->guidType, &GUID_RyAxis, sizeof pDeviceObject->guidType) == 0) { + } else if (SDL_memcmp(&pDeviceObject->guidType, &GUID_RyAxis, sizeof(pDeviceObject->guidType)) == 0) { in->ofs = DIJOFS_RY; - } else if (SDL_memcmp(&pDeviceObject->guidType, &GUID_RzAxis, sizeof pDeviceObject->guidType) == 0) { + } else if (SDL_memcmp(&pDeviceObject->guidType, &GUID_RzAxis, sizeof(pDeviceObject->guidType)) == 0) { in->ofs = DIJOFS_RZ; - } else if (SDL_memcmp(&pDeviceObject->guidType, &GUID_Slider, sizeof pDeviceObject->guidType) == 0) { + } else if (SDL_memcmp(&pDeviceObject->guidType, &GUID_Slider, sizeof(pDeviceObject->guidType)) == 0) { in->ofs = DIJOFS_SLIDER(joystick->hwdata->NumSliders); ++joystick->hwdata->NumSliders; } else { diff --git a/src/joystick/windows/SDL_windows_gaming_input.c b/src/joystick/windows/SDL_windows_gaming_input.c index 92a463c5b..bd2cb1379 100644 --- a/src/joystick/windows/SDL_windows_gaming_input.c +++ b/src/joystick/windows/SDL_windows_gaming_input.c @@ -97,9 +97,11 @@ static const IID IID_IRacingWheelStatics = { 0x3AC12CD5, 0x581B, 0x4936, { 0x9F, static const IID IID_IRacingWheelStatics2 = { 0xE666BCAA, 0xEDFD, 0x4323, { 0xA9, 0xF6, 0x3C, 0x38, 0x40, 0x48, 0xD1, 0xED } }; /*static const IID IID_IRacingWheel = { 0xF546656F, 0xE106, 0x4C82, { 0xA9, 0x0F, 0x55, 0x40, 0x12, 0x90, 0x4B, 0x85 } };*/ + extern SDL_bool SDL_XINPUT_Enabled(void); extern SDL_bool SDL_DINPUT_JoystickPresent(Uint16 vendor, Uint16 product, Uint16 version); + static SDL_bool SDL_IsXInputDevice(Uint16 vendor, Uint16 product) { #ifdef SDL_JOYSTICK_XINPUT @@ -185,7 +187,7 @@ static SDL_bool SDL_IsXInputDevice(Uint16 vendor, Uint16 product) continue; } - (void)SDL_snprintf(devVidPidString, sizeof devVidPidString, "VID_%04X&PID_%04X", vendor, product); + (void)SDL_snprintf(devVidPidString, sizeof(devVidPidString), "VID_%04X&PID_%04X", vendor, product); while (CM_Get_Parent(&devNode, devNode, 0) == CR_SUCCESS) { char deviceId[MAX_DEVICE_ID_LEN]; diff --git a/src/joystick/windows/SDL_xinputjoystick.c b/src/joystick/windows/SDL_xinputjoystick.c index 85c36afc3..24b47f02d 100644 --- a/src/joystick/windows/SDL_xinputjoystick.c +++ b/src/joystick/windows/SDL_xinputjoystick.c @@ -84,37 +84,37 @@ static const char *GetXInputName(const Uint8 userid, BYTE SubType) static char name[32]; if (SDL_XInputUseOldJoystickMapping()) { - (void)SDL_snprintf(name, sizeof name, "X360 Controller #%u", 1 + userid); + (void)SDL_snprintf(name, sizeof(name), "X360 Controller #%u", 1 + userid); } else { switch (SubType) { case XINPUT_DEVSUBTYPE_GAMEPAD: - (void)SDL_snprintf(name, sizeof name, "XInput Controller #%u", 1 + userid); + (void)SDL_snprintf(name, sizeof(name), "XInput Controller #%u", 1 + userid); break; case XINPUT_DEVSUBTYPE_WHEEL: - (void)SDL_snprintf(name, sizeof name, "XInput Wheel #%u", 1 + userid); + (void)SDL_snprintf(name, sizeof(name), "XInput Wheel #%u", 1 + userid); break; case XINPUT_DEVSUBTYPE_ARCADE_STICK: - (void)SDL_snprintf(name, sizeof name, "XInput ArcadeStick #%u", 1 + userid); + (void)SDL_snprintf(name, sizeof(name), "XInput ArcadeStick #%u", 1 + userid); break; case XINPUT_DEVSUBTYPE_FLIGHT_STICK: - (void)SDL_snprintf(name, sizeof name, "XInput FlightStick #%u", 1 + userid); + (void)SDL_snprintf(name, sizeof(name), "XInput FlightStick #%u", 1 + userid); break; case XINPUT_DEVSUBTYPE_DANCE_PAD: - (void)SDL_snprintf(name, sizeof name, "XInput DancePad #%u", 1 + userid); + (void)SDL_snprintf(name, sizeof(name), "XInput DancePad #%u", 1 + userid); break; case XINPUT_DEVSUBTYPE_GUITAR: case XINPUT_DEVSUBTYPE_GUITAR_ALTERNATE: case XINPUT_DEVSUBTYPE_GUITAR_BASS: - (void)SDL_snprintf(name, sizeof name, "XInput Guitar #%u", 1 + userid); + (void)SDL_snprintf(name, sizeof(name), "XInput Guitar #%u", 1 + userid); break; case XINPUT_DEVSUBTYPE_DRUM_KIT: - (void)SDL_snprintf(name, sizeof name, "XInput DrumKit #%u", 1 + userid); + (void)SDL_snprintf(name, sizeof(name), "XInput DrumKit #%u", 1 + userid); break; case XINPUT_DEVSUBTYPE_ARCADE_PAD: - (void)SDL_snprintf(name, sizeof name, "XInput ArcadePad #%u", 1 + userid); + (void)SDL_snprintf(name, sizeof(name), "XInput ArcadePad #%u", 1 + userid); break; default: - (void)SDL_snprintf(name, sizeof name, "XInput Device #%u", 1 + userid); + (void)SDL_snprintf(name, sizeof(name), "XInput Device #%u", 1 + userid); break; } } @@ -277,7 +277,7 @@ static void AddXInputDevice(Uint8 userid, BYTE SubType, JoyStick_DeviceData **pC SDL_free(pNewJoystick); return; /* better luck next time? */ } - (void)SDL_snprintf(pNewJoystick->path, sizeof pNewJoystick->path, "XInput#%d", userid); + (void)SDL_snprintf(pNewJoystick->path, sizeof(pNewJoystick->path), "XInput#%d", userid); if (!SDL_XInputUseOldJoystickMapping()) { GuessXInputDevice(userid, &vendor, &product, &version); diff --git a/src/sensor/n3ds/SDL_n3dssensor.c b/src/sensor/n3ds/SDL_n3dssensor.c index 6042e4149..c486996f1 100644 --- a/src/sensor/n3ds/SDL_n3dssensor.c +++ b/src/sensor/n3ds/SDL_n3dssensor.c @@ -157,7 +157,7 @@ UpdateN3DSAccelerometer(SDL_Sensor *sensor) data[0] = (float)current_state.x * SDL_STANDARD_GRAVITY; data[1] = (float)current_state.y * SDL_STANDARD_GRAVITY; data[2] = (float)current_state.z * SDL_STANDARD_GRAVITY; - SDL_SendSensorUpdate(timestamp, sensor, timestamp, data, sizeof data); + SDL_SendSensorUpdate(timestamp, sensor, timestamp, data, sizeof(data)); } } @@ -175,7 +175,7 @@ UpdateN3DSGyroscope(SDL_Sensor *sensor) data[0] = (float)current_state.x; data[1] = (float)current_state.y; data[2] = (float)current_state.z; - SDL_SendSensorUpdate(timestamp, sensor, timestamp, data, sizeof data); + SDL_SendSensorUpdate(timestamp, sensor, timestamp, data, sizeof(data)); } } diff --git a/src/test/SDL_test_common.c b/src/test/SDL_test_common.c index 7b049b3df..69fa33003 100644 --- a/src/test/SDL_test_common.c +++ b/src/test/SDL_test_common.c @@ -1015,28 +1015,28 @@ static void SDLTest_PrintRenderer(SDL_RendererInfo *info) SDL_Log(" Renderer %s:\n", info->name); - (void)SDL_snprintf(text, sizeof text, " Flags: 0x%8.8" SDL_PRIX32, info->flags); - SDL_snprintfcat(text, sizeof text, " ("); + (void)SDL_snprintf(text, sizeof(text), " Flags: 0x%8.8" SDL_PRIX32, info->flags); + SDL_snprintfcat(text, sizeof(text), " ("); count = 0; - for (i = 0; i < 8 * sizeof info->flags; ++i) { + for (i = 0; i < 8 * sizeof(info->flags); ++i) { Uint32 flag = (1 << i); if (info->flags & flag) { if (count > 0) { - SDL_snprintfcat(text, sizeof text, " | "); + SDL_snprintfcat(text, sizeof(text), " | "); } - SDLTest_PrintRendererFlag(text, sizeof text, flag); + SDLTest_PrintRendererFlag(text, sizeof(text), flag); ++count; } } - SDL_snprintfcat(text, sizeof text, ")"); + SDL_snprintfcat(text, sizeof(text), ")"); SDL_Log("%s\n", text); - (void)SDL_snprintf(text, sizeof text, " Texture formats (%" SDL_PRIu32 "): ", info->num_texture_formats); + (void)SDL_snprintf(text, sizeof(text), " Texture formats (%" SDL_PRIu32 "): ", info->num_texture_formats); for (i = 0; i < (int)info->num_texture_formats; ++i) { if (i > 0) { - SDL_snprintfcat(text, sizeof text, ", "); + SDL_snprintfcat(text, sizeof(text), ", "); } - SDLTest_PrintPixelFormat(text, sizeof text, info->texture_formats[i]); + SDLTest_PrintPixelFormat(text, sizeof(text), info->texture_formats[i]); } SDL_Log("%s\n", text); @@ -1123,12 +1123,12 @@ SDLTest_CommonInit(SDLTest_CommonState *state) if (n == 0) { SDL_Log("No built-in video drivers\n"); } else { - (void)SDL_snprintf(text, sizeof text, "Built-in video drivers:"); + (void)SDL_snprintf(text, sizeof(text), "Built-in video drivers:"); for (i = 0; i < n; ++i) { if (i > 0) { - SDL_snprintfcat(text, sizeof text, ","); + SDL_snprintfcat(text, sizeof(text), ","); } - SDL_snprintfcat(text, sizeof text, " %s", SDL_GetVideoDriver(i)); + SDL_snprintfcat(text, sizeof(text), " %s", SDL_GetVideoDriver(i)); } SDL_Log("%s\n", text); } @@ -1407,12 +1407,12 @@ SDLTest_CommonInit(SDLTest_CommonState *state) if (n == 0) { SDL_Log("No built-in audio drivers\n"); } else { - (void)SDL_snprintf(text, sizeof text, "Built-in audio drivers:"); + (void)SDL_snprintf(text, sizeof(text), "Built-in audio drivers:"); for (i = 0; i < n; ++i) { if (i > 0) { - SDL_snprintfcat(text, sizeof text, ","); + SDL_snprintfcat(text, sizeof(text), ","); } - SDL_snprintfcat(text, sizeof text, " %s", SDL_GetAudioDriver(i)); + SDL_snprintfcat(text, sizeof(text), " %s", SDL_GetAudioDriver(i)); } SDL_Log("%s\n", text); } @@ -2243,7 +2243,7 @@ void SDLTest_CommonEvent(SDLTest_CommonState *state, SDL_Event *event, int *done char message[256]; SDL_Window *window = SDL_GetWindowFromID(event->key.windowID); - (void)SDL_snprintf(message, sizeof message, "(%g, %g), rel (%g, %g)\n", + (void)SDL_snprintf(message, sizeof(message), "(%g, %g), rel (%g, %g)\n", lastEvent.x, lastEvent.y, lastEvent.xrel, lastEvent.yrel); SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, "Last mouse position", message, window); break; @@ -2330,7 +2330,7 @@ void SDLTest_CommonDrawWindowInfo(SDL_Renderer *renderer, SDL_Window *window, fl SDL_SetRenderDrawColor(renderer, 170, 170, 170, 255); - (void)SDL_snprintf(text, sizeof text, "SDL_GetCurrentVideoDriver: %s", SDL_GetCurrentVideoDriver()); + (void)SDL_snprintf(text, sizeof(text), "SDL_GetCurrentVideoDriver: %s", SDL_GetCurrentVideoDriver()); SDLTest_DrawString(renderer, 0.0f, textY, text); textY += lineHeight; @@ -2343,40 +2343,40 @@ void SDLTest_CommonDrawWindowInfo(SDL_Renderer *renderer, SDL_Window *window, fl SDL_SetRenderDrawColor(renderer, 170, 170, 170, 255); if (0 == SDL_GetRendererInfo(renderer, &info)) { - (void)SDL_snprintf(text, sizeof text, "SDL_GetRendererInfo: name: %s", info.name); + (void)SDL_snprintf(text, sizeof(text), "SDL_GetRendererInfo: name: %s", info.name); SDLTest_DrawString(renderer, 0.0f, textY, text); textY += lineHeight; } if (0 == SDL_GetRenderOutputSize(renderer, &w, &h)) { - (void)SDL_snprintf(text, sizeof text, "SDL_GetRenderOutputSize: %dx%d", w, h); + (void)SDL_snprintf(text, sizeof(text), "SDL_GetRenderOutputSize: %dx%d", w, h); SDLTest_DrawString(renderer, 0.0f, textY, text); textY += lineHeight; } if (0 == SDL_GetCurrentRenderOutputSize(renderer, &w, &h)) { - (void)SDL_snprintf(text, sizeof text, "SDL_GetCurrentRenderOutputSize: %dx%d", w, h); + (void)SDL_snprintf(text, sizeof(text), "SDL_GetCurrentRenderOutputSize: %dx%d", w, h); SDLTest_DrawString(renderer, 0.0f, textY, text); textY += lineHeight; } SDL_GetRenderViewport(renderer, &rect); - (void)SDL_snprintf(text, sizeof text, "SDL_GetRenderViewport: %d,%d, %dx%d", + (void)SDL_snprintf(text, sizeof(text), "SDL_GetRenderViewport: %d,%d, %dx%d", rect.x, rect.y, rect.w, rect.h); SDLTest_DrawString(renderer, 0.0f, textY, text); textY += lineHeight; SDL_GetRenderScale(renderer, &scaleX, &scaleY); - (void)SDL_snprintf(text, sizeof text, "SDL_GetRenderScale: %g,%g", + (void)SDL_snprintf(text, sizeof(text), "SDL_GetRenderScale: %g,%g", scaleX, scaleY); SDLTest_DrawString(renderer, 0.0f, textY, text); textY += lineHeight; SDL_GetRenderLogicalPresentation(renderer, &w, &h, &logical_presentation, &logical_scale_mode); - (void)SDL_snprintf(text, sizeof text, "SDL_GetRenderLogicalPresentation: %dx%d ", w, h); - SDLTest_PrintLogicalPresentation(text, sizeof text, logical_presentation); - SDL_snprintfcat(text, sizeof text, ", "); - SDLTest_PrintScaleMode(text, sizeof text, logical_scale_mode); + (void)SDL_snprintf(text, sizeof(text), "SDL_GetRenderLogicalPresentation: %dx%d ", w, h); + SDLTest_PrintLogicalPresentation(text, sizeof(text), logical_presentation); + SDL_snprintfcat(text, sizeof(text), ", "); + SDLTest_PrintScaleMode(text, sizeof(text), logical_scale_mode); SDLTest_DrawString(renderer, 0.0f, textY, text); textY += lineHeight; @@ -2389,23 +2389,23 @@ void SDLTest_CommonDrawWindowInfo(SDL_Renderer *renderer, SDL_Window *window, fl SDL_SetRenderDrawColor(renderer, 170, 170, 170, 255); SDL_GetWindowPosition(window, &x, &y); - (void)SDL_snprintf(text, sizeof text, "SDL_GetWindowPosition: %d,%d", x, y); + (void)SDL_snprintf(text, sizeof(text), "SDL_GetWindowPosition: %d,%d", x, y); SDLTest_DrawString(renderer, 0.0f, textY, text); textY += lineHeight; SDL_GetWindowSize(window, &w, &h); - (void)SDL_snprintf(text, sizeof text, "SDL_GetWindowSize: %dx%d", w, h); + (void)SDL_snprintf(text, sizeof(text), "SDL_GetWindowSize: %dx%d", w, h); SDLTest_DrawString(renderer, 0.0f, textY, text); textY += lineHeight; - (void)SDL_snprintf(text, sizeof text, "SDL_GetWindowFlags: "); - SDLTest_PrintWindowFlags(text, sizeof text, SDL_GetWindowFlags(window)); + (void)SDL_snprintf(text, sizeof(text), "SDL_GetWindowFlags: "); + SDLTest_PrintWindowFlags(text, sizeof(text), SDL_GetWindowFlags(window)); SDLTest_DrawString(renderer, 0.0f, textY, text); textY += lineHeight; mode = SDL_GetWindowFullscreenMode(window); if (mode) { - (void)SDL_snprintf(text, sizeof text, "SDL_GetWindowFullscreenMode: %dx%d@%gHz %d%% scale, (%s)", + (void)SDL_snprintf(text, sizeof(text), "SDL_GetWindowFullscreenMode: %dx%d@%gHz %d%% scale, (%s)", mode->pixel_w, mode->pixel_h, mode->refresh_rate, (int)(mode->display_scale * 100.0f), SDL_GetPixelFormatName(mode->format)); SDLTest_DrawString(renderer, 0.0f, textY, text); textY += lineHeight; @@ -2419,16 +2419,16 @@ void SDLTest_CommonDrawWindowInfo(SDL_Renderer *renderer, SDL_Window *window, fl SDL_SetRenderDrawColor(renderer, 170, 170, 170, 255); - (void)SDL_snprintf(text, sizeof text, "SDL_GetDisplayForWindow: %" SDL_PRIu32 "", windowDisplayID); + (void)SDL_snprintf(text, sizeof(text), "SDL_GetDisplayForWindow: %" SDL_PRIu32 "", windowDisplayID); SDLTest_DrawString(renderer, 0.0f, textY, text); textY += lineHeight; - (void)SDL_snprintf(text, sizeof text, "SDL_GetDisplayName: %s", SDL_GetDisplayName(windowDisplayID)); + (void)SDL_snprintf(text, sizeof(text), "SDL_GetDisplayName: %s", SDL_GetDisplayName(windowDisplayID)); SDLTest_DrawString(renderer, 0.0f, textY, text); textY += lineHeight; if (0 == SDL_GetDisplayBounds(windowDisplayID, &rect)) { - (void)SDL_snprintf(text, sizeof text, "SDL_GetDisplayBounds: %d,%d, %dx%d", + (void)SDL_snprintf(text, sizeof(text), "SDL_GetDisplayBounds: %d,%d, %dx%d", rect.x, rect.y, rect.w, rect.h); SDLTest_DrawString(renderer, 0.0f, textY, text); textY += lineHeight; @@ -2436,7 +2436,7 @@ void SDLTest_CommonDrawWindowInfo(SDL_Renderer *renderer, SDL_Window *window, fl mode = SDL_GetCurrentDisplayMode(windowDisplayID); if (mode) { - (void)SDL_snprintf(text, sizeof text, "SDL_GetCurrentDisplayMode: %dx%d@%gHz %d%% scale, (%s)", + (void)SDL_snprintf(text, sizeof(text), "SDL_GetCurrentDisplayMode: %dx%d@%gHz %d%% scale, (%s)", mode->pixel_w, mode->pixel_h, mode->refresh_rate, (int)(mode->display_scale * 100.0f), SDL_GetPixelFormatName(mode->format)); SDLTest_DrawString(renderer, 0.0f, textY, text); textY += lineHeight; @@ -2444,14 +2444,14 @@ void SDLTest_CommonDrawWindowInfo(SDL_Renderer *renderer, SDL_Window *window, fl mode = SDL_GetDesktopDisplayMode(windowDisplayID); if (mode) { - (void)SDL_snprintf(text, sizeof text, "SDL_GetDesktopDisplayMode: %dx%d@%gHz %d%% scale, (%s)", + (void)SDL_snprintf(text, sizeof(text), "SDL_GetDesktopDisplayMode: %dx%d@%gHz %d%% scale, (%s)", mode->pixel_w, mode->pixel_h, mode->refresh_rate, (int)(mode->display_scale * 100.0f), SDL_GetPixelFormatName(mode->format)); SDLTest_DrawString(renderer, 0.0f, textY, text); textY += lineHeight; } - (void)SDL_snprintf(text, sizeof text, "SDL_GetDisplayOrientation: "); - SDLTest_PrintDisplayOrientation(text, sizeof text, SDL_GetDisplayOrientation(windowDisplayID)); + (void)SDL_snprintf(text, sizeof(text), "SDL_GetDisplayOrientation: "); + SDLTest_PrintDisplayOrientation(text, sizeof(text), SDL_GetDisplayOrientation(windowDisplayID)); SDLTest_DrawString(renderer, 0.0f, textY, text); textY += lineHeight; @@ -2464,14 +2464,14 @@ void SDLTest_CommonDrawWindowInfo(SDL_Renderer *renderer, SDL_Window *window, fl SDL_SetRenderDrawColor(renderer, 170, 170, 170, 255); flags = SDL_GetMouseState(&fx, &fy); - (void)SDL_snprintf(text, sizeof text, "SDL_GetMouseState: %g,%g ", fx, fy); - SDLTest_PrintButtonMask(text, sizeof text, flags); + (void)SDL_snprintf(text, sizeof(text), "SDL_GetMouseState: %g,%g ", fx, fy); + SDLTest_PrintButtonMask(text, sizeof(text), flags); SDLTest_DrawString(renderer, 0.0f, textY, text); textY += lineHeight; flags = SDL_GetGlobalMouseState(&fx, &fy); - (void)SDL_snprintf(text, sizeof text, "SDL_GetGlobalMouseState: %g,%g ", fx, fy); - SDLTest_PrintButtonMask(text, sizeof text, flags); + (void)SDL_snprintf(text, sizeof(text), "SDL_GetGlobalMouseState: %g,%g ", fx, fy); + SDLTest_PrintButtonMask(text, sizeof(text), flags); SDLTest_DrawString(renderer, 0.0f, textY, text); textY += lineHeight; diff --git a/src/test/SDL_test_font.c b/src/test/SDL_test_font.c index be9a7aee2..6d36a4b4c 100644 --- a/src/test/SDL_test_font.c +++ b/src/test/SDL_test_font.c @@ -3390,7 +3390,7 @@ void SDLTest_TextWindowAddText(SDLTest_TextWindow *textwin, const char *fmt, ... va_list ap; va_start(ap, fmt); - (void)SDL_vsnprintf(text, sizeof text, fmt, ap); + (void)SDL_vsnprintf(text, sizeof(text), fmt, ap); va_end(ap); SDLTest_TextWindowAddTextWithLength(textwin, text, SDL_strlen(text)); diff --git a/src/test/SDL_test_harness.c b/src/test/SDL_test_harness.c index 80ec62d21..0fc0e8991 100644 --- a/src/test/SDL_test_harness.c +++ b/src/test/SDL_test_harness.c @@ -124,8 +124,8 @@ static Uint64 SDLTest_GenerateExecKey(const char *runSeed, const char *suiteName } /* Convert iteration number into a string */ - SDL_memset(iterationString, 0, sizeof iterationString); - (void)SDL_snprintf(iterationString, sizeof iterationString - 1, "%d", iteration); + SDL_memset(iterationString, 0, sizeof(iterationString)); + (void)SDL_snprintf(iterationString, sizeof(iterationString) - 1, "%d", iteration); /* Combine the parameters into single string */ runSeedLength = SDL_strlen(runSeed); diff --git a/src/test/SDL_test_log.c b/src/test/SDL_test_log.c index fa5b72f17..3923f703a 100644 --- a/src/test/SDL_test_log.c +++ b/src/test/SDL_test_log.c @@ -68,7 +68,7 @@ SDLTest_TimestampToString(const time_t timestamp) SDL_memset(buffer, 0, sizeof(buffer)); copy = timestamp; local = localtime(©); - result = strftime(buffer, sizeof buffer, "%x %X", local); + result = strftime(buffer, sizeof(buffer), "%x %X", local); if (result == 0) { return ""; } diff --git a/src/test/SDL_test_memory.c b/src/test/SDL_test_memory.c index 95d5b73f7..65c3c2a6d 100644 --- a/src/test/SDL_test_memory.c +++ b/src/test/SDL_test_memory.c @@ -243,30 +243,30 @@ void SDLTest_LogAllocations(void) message = tmp; \ SDL_strlcat(message, line, message_size) - SDL_strlcpy(line, "Memory allocations:\n", sizeof line); + SDL_strlcpy(line, "Memory allocations:\n", sizeof(line)); ADD_LINE(); - SDL_strlcpy(line, "Expect 2 allocations from within SDL_GetErrBuf()\n", sizeof line); + SDL_strlcpy(line, "Expect 2 allocations from within SDL_GetErrBuf()\n", sizeof(line)); ADD_LINE(); count = 0; total_allocated = 0; for (index = 0; index < SDL_arraysize(s_tracked_allocations); ++index) { for (entry = s_tracked_allocations[index]; entry; entry = entry->next) { - (void)SDL_snprintf(line, sizeof line, "Allocation %d: %d bytes\n", count, (int)entry->size); + (void)SDL_snprintf(line, sizeof(line), "Allocation %d: %d bytes\n", count, (int)entry->size); ADD_LINE(); /* Start at stack index 1 to skip our tracking functions */ for (stack_index = 1; stack_index < SDL_arraysize(entry->stack); ++stack_index) { if (!entry->stack[stack_index]) { break; } - (void)SDL_snprintf(line, sizeof line, "\t0x%" SDL_PRIx64 ": %s\n", entry->stack[stack_index], entry->stack_names[stack_index]); + (void)SDL_snprintf(line, sizeof(line), "\t0x%" SDL_PRIx64 ": %s\n", entry->stack[stack_index], entry->stack_names[stack_index]); ADD_LINE(); } total_allocated += entry->size; ++count; } } - (void)SDL_snprintf(line, sizeof line, "Total: %.2f Kb in %d allocations\n", total_allocated / 1024.0, count); + (void)SDL_snprintf(line, sizeof(line), "Total: %.2f Kb in %d allocations\n", total_allocated / 1024.0, count); ADD_LINE(); #undef ADD_LINE diff --git a/src/video/dummy/SDL_nullframebuffer.c b/src/video/dummy/SDL_nullframebuffer.c index 96a2cad6e..935e37315 100644 --- a/src/video/dummy/SDL_nullframebuffer.c +++ b/src/video/dummy/SDL_nullframebuffer.c @@ -64,7 +64,7 @@ int SDL_DUMMY_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect /* Send the data to the display */ if (SDL_getenv("SDL_VIDEO_DUMMY_SAVE_FRAMES")) { char file[128]; - (void)SDL_snprintf(file, sizeof file, "SDL_window%" SDL_PRIu32 "-%8.8d.bmp", + (void)SDL_snprintf(file, sizeof(file), "SDL_window%" SDL_PRIu32 "-%8.8d.bmp", SDL_GetWindowID(window), ++frame_number); SDL_SaveBMP(surface, file); } diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c index 1225f27be..24b66e92e 100644 --- a/src/video/kmsdrm/SDL_kmsdrmvideo.c +++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c @@ -218,7 +218,7 @@ static int KMSDRM_Available(void) kmsdrm_dri_pathsize = SDL_strlen(kmsdrm_dri_path); kmsdrm_dri_devnamesize = SDL_strlen(kmsdrm_dri_devname); - (void)SDL_snprintf(kmsdrm_dri_cardpath, sizeof kmsdrm_dri_cardpath, "%s%s", + (void)SDL_snprintf(kmsdrm_dri_cardpath, sizeof(kmsdrm_dri_cardpath), "%s%s", kmsdrm_dri_path, kmsdrm_dri_devname); ret = get_driindex(); @@ -914,7 +914,7 @@ static int KMSDRM_InitDisplays(_THIS) int i; /* Open /dev/dri/cardNN (/dev/drmN if on OpenBSD version less than 6.9) */ - (void)SDL_snprintf(viddata->devpath, sizeof viddata->devpath, "%s%d", + (void)SDL_snprintf(viddata->devpath, sizeof(viddata->devpath), "%s%d", kmsdrm_dri_cardpath, viddata->devindex); SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Opening device %s", viddata->devpath); diff --git a/src/video/offscreen/SDL_offscreenframebuffer.c b/src/video/offscreen/SDL_offscreenframebuffer.c index 5eff510fd..aeba83e22 100644 --- a/src/video/offscreen/SDL_offscreenframebuffer.c +++ b/src/video/offscreen/SDL_offscreenframebuffer.c @@ -48,6 +48,7 @@ int SDL_OFFSCREEN_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *for *format = surface_format; *pixels = surface->pixels; *pitch = surface->pitch; + return 0; } @@ -64,7 +65,7 @@ int SDL_OFFSCREEN_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_R /* Send the data to the display */ if (SDL_getenv("SDL_VIDEO_OFFSCREEN_SAVE_FRAMES")) { char file[128]; - (void)SDL_snprintf(file, sizeof file, "SDL_window%" SDL_PRIu32 "-%8.8d.bmp", + (void)SDL_snprintf(file, sizeof(file), "SDL_window%" SDL_PRIu32 "-%8.8d.bmp", SDL_GetWindowID(window), ++frame_number); SDL_SaveBMP(surface, file); } diff --git a/src/video/wayland/SDL_waylandevents.c b/src/video/wayland/SDL_waylandevents.c index b8023078a..952aa5d41 100644 --- a/src/video/wayland/SDL_waylandevents.c +++ b/src/video/wayland/SDL_waylandevents.c @@ -78,6 +78,7 @@ #define XKB_MOD_NAME_MODE "Mod5" #endif + struct SDL_WaylandTouchPoint { SDL_TouchID id; @@ -876,7 +877,7 @@ static void pointer_handle_frame(void *data, struct wl_pointer *pointer) } /* clear pointer_curr_axis_info for next frame */ - SDL_memset(&input->pointer_curr_axis_info, 0, sizeof input->pointer_curr_axis_info); + SDL_memset(&input->pointer_curr_axis_info, 0, sizeof(input->pointer_curr_axis_info)); if (x != 0.0f || y != 0.0f) { SDL_SendMouseWheel(input->pointer_curr_axis_info.timestamp_ns, @@ -1581,7 +1582,7 @@ static void seat_handle_capabilities(void *data, struct wl_seat *seat, if ((caps & WL_SEAT_CAPABILITY_POINTER) && !input->pointer) { input->pointer = wl_seat_get_pointer(seat); - SDL_memset(&input->pointer_curr_axis_info, 0, sizeof input->pointer_curr_axis_info); + SDL_memset(&input->pointer_curr_axis_info, 0, sizeof(input->pointer_curr_axis_info)); input->display->pointer = input->pointer; wl_pointer_set_user_data(input->pointer, input); wl_pointer_add_listener(input->pointer, &pointer_listener, @@ -1701,7 +1702,7 @@ SDL_WaylandDataSource *Wayland_data_source_create(_THIS) if (id == NULL) { SDL_SetError("Wayland unable to create data source"); } else { - data_source = SDL_calloc(1, sizeof *data_source); + data_source = SDL_calloc(1, sizeof(*data_source)); if (data_source == NULL) { SDL_OutOfMemory(); wl_data_source_destroy(id); @@ -1736,7 +1737,7 @@ SDL_WaylandPrimarySelectionSource *Wayland_primary_selection_source_create(_THIS if (id == NULL) { SDL_SetError("Wayland unable to create primary selection source"); } else { - primary_selection_source = SDL_calloc(1, sizeof *primary_selection_source); + primary_selection_source = SDL_calloc(1, sizeof(*primary_selection_source)); if (primary_selection_source == NULL) { SDL_OutOfMemory(); zwp_primary_selection_source_v1_destroy(id); @@ -1790,7 +1791,7 @@ static void data_device_handle_data_offer(void *data, struct wl_data_device *wl_ { SDL_WaylandDataOffer *data_offer = NULL; - data_offer = SDL_calloc(1, sizeof *data_offer); + data_offer = SDL_calloc(1, sizeof(*data_offer)); if (data_offer == NULL) { SDL_OutOfMemory(); } else { @@ -2060,7 +2061,7 @@ static void primary_selection_device_handle_offer(void *data, struct zwp_primary { SDL_WaylandPrimarySelectionOffer *primary_selection_offer = NULL; - primary_selection_offer = SDL_calloc(1, sizeof *primary_selection_offer); + primary_selection_offer = SDL_calloc(1, sizeof(*primary_selection_offer)); if (primary_selection_offer == NULL) { SDL_OutOfMemory(); } else { @@ -2201,7 +2202,7 @@ static void Wayland_create_data_device(SDL_VideoData *d) { SDL_WaylandDataDevice *data_device = NULL; - data_device = SDL_calloc(1, sizeof *data_device); + data_device = SDL_calloc(1, sizeof(*data_device)); if (data_device == NULL) { return; } @@ -2224,7 +2225,7 @@ static void Wayland_create_primary_selection_device(SDL_VideoData *d) { SDL_WaylandPrimarySelectionDevice *primary_selection_device = NULL; - primary_selection_device = SDL_calloc(1, sizeof *primary_selection_device); + primary_selection_device = SDL_calloc(1, sizeof(*primary_selection_device)); if (primary_selection_device == NULL) { return; } @@ -2248,7 +2249,7 @@ static void Wayland_create_text_input(SDL_VideoData *d) { SDL_WaylandTextInput *text_input = NULL; - text_input = SDL_calloc(1, sizeof *text_input); + text_input = SDL_calloc(1, sizeof(*text_input)); if (text_input == NULL) { return; } @@ -2516,7 +2517,7 @@ static struct SDL_WaylandTabletObjectListNode *tablet_object_list_new_node(void { struct SDL_WaylandTabletObjectListNode *node; - node = SDL_calloc(1, sizeof *node); + node = SDL_calloc(1, sizeof(*node)); if (node == NULL) { return NULL; } @@ -2591,7 +2592,7 @@ void Wayland_input_add_tablet(struct SDL_WaylandInput *input, struct SDL_Wayland return; } - tablet_input = SDL_calloc(1, sizeof *tablet_input); + tablet_input = SDL_calloc(1, sizeof(*tablet_input)); if (tablet_input == NULL) { return; } @@ -2624,7 +2625,7 @@ void Wayland_display_add_input(SDL_VideoData *d, uint32_t id, uint32_t version) { struct SDL_WaylandInput *input; - input = SDL_calloc(1, sizeof *input); + input = SDL_calloc(1, sizeof(*input)); if (input == NULL) { return; } diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c index 6bad7cdad..433ac37a8 100644 --- a/src/video/wayland/SDL_waylandwindow.c +++ b/src/video/wayland/SDL_waylandwindow.c @@ -1811,7 +1811,7 @@ int Wayland_CreateWindow(_THIS, SDL_Window *window) SDL_WindowData *data; SDL_VideoData *c; - data = SDL_calloc(1, sizeof *data); + data = SDL_calloc(1, sizeof(*data)); if (data == NULL) { return SDL_OutOfMemory(); } diff --git a/src/video/x11/SDL_x11keyboard.c b/src/video/x11/SDL_x11keyboard.c index 28dd2c958..0cd76eaa7 100644 --- a/src/video/x11/SDL_x11keyboard.c +++ b/src/video/x11/SDL_x11keyboard.c @@ -446,7 +446,7 @@ void X11_ShowScreenKeyboard(_THIS, SDL_Window *window) * https://partner.steamgames.com/doc/api/ISteamUtils#ShowFloatingGamepadTextInput */ char deeplink[128]; - (void)SDL_snprintf(deeplink, sizeof deeplink, + (void)SDL_snprintf(deeplink, sizeof(deeplink), "steam://open/keyboard?XPosition=0&YPosition=0&Width=0&Height=0&Mode=%d", SDL_GetHintBoolean(SDL_HINT_RETURN_KEY_HIDES_IME, SDL_FALSE) ? 0 : 1); SDL_OpenURL(deeplink); diff --git a/test/checkkeys.c b/test/checkkeys.c index 78b72651c..b9cb97f10 100644 --- a/test/checkkeys.c +++ b/test/checkkeys.c @@ -160,7 +160,7 @@ PrintText(const char *eventtype, const char *text) expanded[0] = '\0'; for (spot = text; *spot; ++spot) { size_t length = SDL_strlen(expanded); - (void)SDL_snprintf(expanded + length, sizeof expanded - length, "\\x%.2x", (unsigned char)*spot); + (void)SDL_snprintf(expanded + length, sizeof(expanded) - length, "\\x%.2x", (unsigned char)*spot); } SDL_Log("%s Text (%s): \"%s%s\"\n", eventtype, expanded, *text == '"' ? "\\" : "", text); } diff --git a/test/checkkeysthreads.c b/test/checkkeysthreads.c index 7ba3d8720..0a8cb7947 100644 --- a/test/checkkeysthreads.c +++ b/test/checkkeysthreads.c @@ -157,7 +157,7 @@ PrintText(const char *eventtype, const char *text) expanded[0] = '\0'; for (spot = text; *spot; ++spot) { size_t length = SDL_strlen(expanded); - (void)SDL_snprintf(expanded + length, sizeof expanded - length, "\\x%.2x", (unsigned char)*spot); + (void)SDL_snprintf(expanded + length, sizeof(expanded) - length, "\\x%.2x", (unsigned char)*spot); } SDL_Log("%s Text (%s): \"%s%s\"\n", eventtype, expanded, *text == '"' ? "\\" : "", text); } diff --git a/test/gamepadmap.c b/test/gamepadmap.c index f41968da6..51f98c0e6 100644 --- a/test/gamepadmap.c +++ b/test/gamepadmap.c @@ -593,7 +593,7 @@ WatchJoystick(SDL_Joystick *joystick) char crc_string[5]; SDL_strlcat(mapping, "crc:", SDL_arraysize(mapping)); - (void)SDL_snprintf(crc_string, sizeof crc_string, "%.4x", crc); + (void)SDL_snprintf(crc_string, sizeof(crc_string), "%.4x", crc); SDL_strlcat(mapping, crc_string, SDL_arraysize(mapping)); SDL_strlcat(mapping, ",", SDL_arraysize(mapping)); } @@ -666,17 +666,17 @@ WatchJoystick(SDL_Joystick *joystick) pszElement[0] = '\0'; switch (pBinding->bindType) { case SDL_GAMEPAD_BINDTYPE_BUTTON: - (void)SDL_snprintf(pszElement, sizeof pszElement, "b%d", pBinding->value.button); + (void)SDL_snprintf(pszElement, sizeof(pszElement), "b%d", pBinding->value.button); break; case SDL_GAMEPAD_BINDTYPE_AXIS: if (pBinding->value.axis.axis_min == 0 && pBinding->value.axis.axis_max == SDL_JOYSTICK_AXIS_MIN) { /* The negative half axis */ - (void)SDL_snprintf(pszElement, sizeof pszElement, "-a%d", pBinding->value.axis.axis); + (void)SDL_snprintf(pszElement, sizeof(pszElement), "-a%d", pBinding->value.axis.axis); } else if (pBinding->value.axis.axis_min == 0 && pBinding->value.axis.axis_max == SDL_JOYSTICK_AXIS_MAX) { /* The positive half axis */ - (void)SDL_snprintf(pszElement, sizeof pszElement, "+a%d", pBinding->value.axis.axis); + (void)SDL_snprintf(pszElement, sizeof(pszElement), "+a%d", pBinding->value.axis.axis); } else { - (void)SDL_snprintf(pszElement, sizeof pszElement, "a%d", pBinding->value.axis.axis); + (void)SDL_snprintf(pszElement, sizeof(pszElement), "a%d", pBinding->value.axis.axis); if (pBinding->value.axis.axis_min > pBinding->value.axis.axis_max) { /* Invert the axis */ SDL_strlcat(pszElement, "~", SDL_arraysize(pszElement)); @@ -684,7 +684,7 @@ WatchJoystick(SDL_Joystick *joystick) } break; case SDL_GAMEPAD_BINDTYPE_HAT: - (void)SDL_snprintf(pszElement, sizeof pszElement, "h%d.%d", pBinding->value.hat.hat, pBinding->value.hat.hat_mask); + (void)SDL_snprintf(pszElement, sizeof(pszElement), "h%d.%d", pBinding->value.hat.hat, pBinding->value.hat.hat_mask); break; default: SDL_assert(!"Unknown bind type"); diff --git a/test/testatomic.c b/test/testatomic.c index 776c7dd16..53feb9796 100644 --- a/test/testatomic.c +++ b/test/testatomic.c @@ -614,7 +614,7 @@ static void RunFIFOTest(SDL_bool lock_free) SDL_zeroa(readerData); for (i = 0; i < NUM_READERS; ++i) { char name[64]; - (void)SDL_snprintf(name, sizeof name, "FIFOReader%d", i); + (void)SDL_snprintf(name, sizeof(name), "FIFOReader%d", i); readerData[i].queue = &queue; readerData[i].lock_free = lock_free; readerData[i].thread = SDL_CreateThread(FIFO_Reader, name, &readerData[i]); @@ -625,7 +625,7 @@ static void RunFIFOTest(SDL_bool lock_free) SDL_zeroa(writerData); for (i = 0; i < NUM_WRITERS; ++i) { char name[64]; - (void)SDL_snprintf(name, sizeof name, "FIFOWriter%d", i); + (void)SDL_snprintf(name, sizeof(name), "FIFOWriter%d", i); writerData[i].queue = &queue; writerData[i].index = i; writerData[i].lock_free = lock_free; @@ -674,17 +674,17 @@ static void RunFIFOTest(SDL_bool lock_free) } grand_total += total; SDL_Log("Reader %d read %d events, had %d waits\n", i, total, readerData[i].waits); - (void)SDL_snprintf(textBuffer, sizeof textBuffer, " { "); + (void)SDL_snprintf(textBuffer, sizeof(textBuffer), " { "); for (j = 0; j < NUM_WRITERS; ++j) { if (j > 0) { len = SDL_strlen(textBuffer); - (void)SDL_snprintf(textBuffer + len, sizeof textBuffer - len, ", "); + (void)SDL_snprintf(textBuffer + len, sizeof(textBuffer) - len, ", "); } len = SDL_strlen(textBuffer); - (void)SDL_snprintf(textBuffer + len, sizeof textBuffer - len, "%d", readerData[i].counters[j]); + (void)SDL_snprintf(textBuffer + len, sizeof(textBuffer) - len, "%d", readerData[i].counters[j]); } len = SDL_strlen(textBuffer); - (void)SDL_snprintf(textBuffer + len, sizeof textBuffer - len, " }\n"); + (void)SDL_snprintf(textBuffer + len, sizeof(textBuffer) - len, " }\n"); SDL_Log("%s", textBuffer); } SDL_Log("Readers read %d total events\n", grand_total); diff --git a/test/testdisplayinfo.c b/test/testdisplayinfo.c index 85275fac8..0a79b20ae 100644 --- a/test/testdisplayinfo.c +++ b/test/testdisplayinfo.c @@ -75,7 +75,7 @@ int main(int argc, char *argv[]) for (m = 0; m < num_modes; m++) { char prefix[64]; - (void)SDL_snprintf(prefix, sizeof prefix, " MODE %d", m); + (void)SDL_snprintf(prefix, sizeof(prefix), " MODE %d", m); print_mode(prefix, modes[i]); } SDL_free(modes); diff --git a/test/testlock.c b/test/testlock.c index fcb790e8a..a4abc0bd3 100644 --- a/test/testlock.c +++ b/test/testlock.c @@ -27,7 +27,7 @@ static SDL_AtomicInt doterminate; /** * SDL_Quit() shouldn't be used with atexit() directly because - * calling conventions may differ... + * calling conventions may differ... */ static void SDL_Quit_Wrapper(void) @@ -116,7 +116,7 @@ int main(int argc, char *argv[]) (void)atexit(printid); for (i = 0; i < maxproc; ++i) { char name[64]; - (void)SDL_snprintf(name, sizeof name, "Worker%d", i); + (void)SDL_snprintf(name, sizeof(name), "Worker%d", i); threads[i] = SDL_CreateThread(Run, name, NULL); if (threads[i] == NULL) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread!\n"); diff --git a/test/testoffscreen.c b/test/testoffscreen.c index 78c1b382d..e6af313ab 100644 --- a/test/testoffscreen.c +++ b/test/testoffscreen.c @@ -61,7 +61,7 @@ static void save_surface_to_bmp(void) SDL_RenderReadPixels(renderer, NULL, pixel_format, surface->pixels, surface->pitch); - (void)SDL_snprintf(file, sizeof file, "SDL_window%" SDL_PRIs32 "-%8.8d.bmp", + (void)SDL_snprintf(file, sizeof(file), "SDL_window%" SDL_PRIs32 "-%8.8d.bmp", SDL_GetWindowID(window), ++frame_number); SDL_SaveBMP(surface, file); @@ -113,8 +113,7 @@ int main(int argc, char *argv[]) window = SDL_CreateWindow("Offscreen Test", width, height, 0); if (window == NULL) { - SDL_Log("Couldn't create window: %s\n", - SDL_GetError()); + SDL_Log("Couldn't create window: %s\n", SDL_GetError()); return SDL_FALSE; } diff --git a/test/testsem.c b/test/testsem.c index db1940015..3608ef55b 100644 --- a/test/testsem.c +++ b/test/testsem.c @@ -75,7 +75,7 @@ TestRealWorld(int init_sem) /* Create all the threads */ for (i = 0; i < NUM_THREADS; ++i) { char name[64]; - (void)SDL_snprintf(name, sizeof name, "Thread%u", (unsigned int)i); + (void)SDL_snprintf(name, sizeof(name), "Thread%u", (unsigned int)i); thread_states[i].number = i; thread_states[i].thread = SDL_CreateThread(ThreadFuncRealWorld, name, (void *)&thread_states[i]); } @@ -197,7 +197,7 @@ TestOverheadContended(SDL_bool try_wait) /* Create multiple threads to starve the semaphore and cause contention */ for (i = 0; i < NUM_THREADS; ++i) { char name[64]; - (void)SDL_snprintf(name, sizeof name, "Thread%u", (unsigned int)i); + (void)SDL_snprintf(name, sizeof(name), "Thread%u", (unsigned int)i); thread_states[i].flag = try_wait; thread_states[i].thread = SDL_CreateThread(ThreadFuncOverheadContended, name, (void *)&thread_states[i]); } @@ -230,17 +230,17 @@ TestOverheadContended(SDL_bool try_wait) duration, try_wait ? "where contended" : "timed out", content_count, loop_count, ((float)content_count * 100) / loop_count); /* Print how many semaphores where consumed per thread */ - (void)SDL_snprintf(textBuffer, sizeof textBuffer, "{ "); + (void)SDL_snprintf(textBuffer, sizeof(textBuffer), "{ "); for (i = 0; i < NUM_THREADS; ++i) { if (i > 0) { len = SDL_strlen(textBuffer); - (void)SDL_snprintf(textBuffer + len, sizeof textBuffer - len, ", "); + (void)SDL_snprintf(textBuffer + len, sizeof(textBuffer) - len, ", "); } len = SDL_strlen(textBuffer); - (void)SDL_snprintf(textBuffer + len, sizeof textBuffer - len, "%d", thread_states[i].loop_count - thread_states[i].content_count); + (void)SDL_snprintf(textBuffer + len, sizeof(textBuffer) - len, "%d", thread_states[i].loop_count - thread_states[i].content_count); } len = SDL_strlen(textBuffer); - (void)SDL_snprintf(textBuffer + len, sizeof textBuffer - len, " }\n"); + (void)SDL_snprintf(textBuffer + len, sizeof(textBuffer) - len, " }\n"); SDL_Log("%s\n", textBuffer); SDL_DestroySemaphore(sem); diff --git a/test/testsensor.c b/test/testsensor.c index fb731e378..955ad80a7 100644 --- a/test/testsensor.c +++ b/test/testsensor.c @@ -29,7 +29,7 @@ static const char *GetSensorTypeString(SDL_SensorType type) case SDL_SENSOR_GYRO: return "SDL_SENSOR_GYRO"; default: - (void)SDL_snprintf(unknown_type, sizeof unknown_type, "UNKNOWN (%d)", type); + (void)SDL_snprintf(unknown_type, sizeof(unknown_type), "UNKNOWN (%d)", type); return unknown_type; } } diff --git a/test/testwm.c b/test/testwm.c index 456446a67..301f4f74d 100644 --- a/test/testwm.c +++ b/test/testwm.c @@ -82,12 +82,12 @@ draw_modes_menu(SDL_Window *window, SDL_Renderer *renderer, SDL_FRect viewport) y += lineHeight; - SDL_strlcpy(text, "Click on a mode to set it with SDL_SetWindowFullscreenMode", sizeof text); + SDL_strlcpy(text, "Click on a mode to set it with SDL_SetWindowFullscreenMode", sizeof(text)); SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255); SDLTest_DrawString(renderer, x, y, text); y += lineHeight; - SDL_strlcpy(text, "Press Ctrl+Enter to toggle SDL_WINDOW_FULLSCREEN", sizeof text); + SDL_strlcpy(text, "Press Ctrl+Enter to toggle SDL_WINDOW_FULLSCREEN", sizeof(text)); SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255); SDLTest_DrawString(renderer, x, y, text); y += lineHeight; @@ -109,7 +109,7 @@ draw_modes_menu(SDL_Window *window, SDL_Renderer *renderer, SDL_FRect viewport) SDL_FRect cell_rect; const SDL_DisplayMode *mode = modes[j]; - (void)SDL_snprintf(text, sizeof text, "%s mode %d: %dx%d@%gHz", + (void)SDL_snprintf(text, sizeof(text), "%s mode %d: %dx%d@%gHz", SDL_GetDisplayName(display_id), j, mode->pixel_w, mode->pixel_h, mode->refresh_rate); diff --git a/test/testyuv.c b/test/testyuv.c index 2d8284360..143ebd6d7 100644 --- a/test/testyuv.c +++ b/test/testyuv.c @@ -430,7 +430,7 @@ int main(int argc, char **argv) if (current == 0) { SDLTest_DrawString(renderer, 4, 4, titles[current]); } else { - (void)SDL_snprintf(title, sizeof title, "%s %s %s", titles[current], yuv_name, yuv_mode); + (void)SDL_snprintf(title, sizeof(title), "%s %s %s", titles[current], yuv_name, yuv_mode); SDLTest_DrawString(renderer, 4, 4, title); } SDL_RenderPresent(renderer); diff --git a/test/torturethread.c b/test/torturethread.c index 22a86816c..534adc599 100644 --- a/test/torturethread.c +++ b/test/torturethread.c @@ -51,7 +51,7 @@ ThreadFunc(void *data) for (i = 0; i < NUMTHREADS; i++) { char name[64]; - (void)SDL_snprintf(name, sizeof name, "Child%d_%d", tid, i); + (void)SDL_snprintf(name, sizeof(name), "Child%d_%d", tid, i); flags[i] = 0; sub_threads[i] = SDL_CreateThread(SubThreadFunc, name, &flags[i]); } @@ -89,7 +89,7 @@ int main(int argc, char *argv[]) (void)signal(SIGSEGV, SIG_DFL); for (i = 0; i < NUMTHREADS; i++) { char name[64]; - (void)SDL_snprintf(name, sizeof name, "Parent%d", i); + (void)SDL_snprintf(name, sizeof(name), "Parent%d", i); SDL_AtomicSet(&time_for_threads_to_die[i], 0); threads[i] = SDL_CreateThread(ThreadFunc, name, (void *)(uintptr_t)i);