Clang-Tidy fixes (#6725)

(cherry picked from commit 3c501b963d)
This commit is contained in:
Pierre Wendling
2022-12-01 16:07:03 -05:00
committed by Sam Lantinga
parent e29c0661cc
commit d0bbfdbfb8
179 changed files with 1260 additions and 1101 deletions

View File

@@ -2480,7 +2480,6 @@ void Android_JNI_DestroyCustomCursor(int cursorID)
{
JNIEnv *env = Android_JNI_GetEnv();
(*env)->CallStaticVoidMethod(env, mActivityClass, midDestroyCustomCursor, cursorID);
return;
}
SDL_bool Android_JNI_SetCustomCursor(int cursorID)

View File

@@ -128,8 +128,7 @@ static int SDL_EVDEV_device_removed(const char *dev_path);
static int SDL_EVDEV_device_added(const char *dev_path, int udev_class);
#if SDL_USE_LIBUDEV
static void SDL_EVDEV_udev_callback(SDL_UDEV_deviceevent udev_type, int udev_class,
const char *dev_path);
static void SDL_EVDEV_udev_callback(SDL_UDEV_deviceevent udev_event, int udev_class, const char *dev_path);
#endif /* SDL_USE_LIBUDEV */
static Uint8 EVDEV_MouseButtons[] = {
@@ -319,10 +318,11 @@ void SDL_EVDEV_Poll(void)
next finger after earlist is released) */
if (item->is_touchscreen && events[i].code == BTN_TOUCH) {
if (item->touchscreen_data->max_slots == 1) {
if (events[i].value)
if (events[i].value) {
item->touchscreen_data->slots[0].delta = EVDEV_TOUCH_SLOTDELTA_DOWN;
else
} else {
item->touchscreen_data->slots[0].delta = EVDEV_TOUCH_SLOTDELTA_UP;
}
}
break;
}
@@ -820,8 +820,8 @@ static int SDL_EVDEV_device_added(const char *dev_path, int udev_class)
/* For now, we just treat a touchpad like a touchscreen */
if (udev_class & (SDL_UDEV_DEVICE_TOUCHSCREEN | SDL_UDEV_DEVICE_TOUCHPAD)) {
item->is_touchscreen = SDL_TRUE;
if ((ret = SDL_EVDEV_init_touchscreen(item, udev_class)) < 0) {
ret = SDL_EVDEV_init_touchscreen(item, udev_class);
if (ret < 0) {
close(item->fd);
SDL_free(item->path);
SDL_free(item);

View File

@@ -37,10 +37,10 @@
#endif
extern int
SDL_EVDEV_GuessDeviceClass(unsigned long bitmask_ev[NBITS(EV_MAX)],
unsigned long bitmask_abs[NBITS(ABS_MAX)],
unsigned long bitmask_key[NBITS(KEY_MAX)],
unsigned long bitmask_rel[NBITS(REL_MAX)])
SDL_EVDEV_GuessDeviceClass(const unsigned long bitmask_ev[NBITS(EV_MAX)],
const unsigned long bitmask_abs[NBITS(ABS_MAX)],
const unsigned long bitmask_key[NBITS(KEY_MAX)],
const unsigned long bitmask_rel[NBITS(REL_MAX)])
{
struct range
{

View File

@@ -47,10 +47,10 @@ typedef enum
#define EVDEV_LONG(x) ((x) / BITS_PER_LONG)
#define test_bit(bit, array) ((array[EVDEV_LONG(bit)] >> EVDEV_OFF(bit)) & 1)
extern int SDL_EVDEV_GuessDeviceClass(unsigned long bitmask_ev[NBITS(EV_MAX)],
unsigned long bitmask_abs[NBITS(ABS_MAX)],
unsigned long bitmask_key[NBITS(KEY_MAX)],
unsigned long bitmask_rel[NBITS(REL_MAX)]);
extern int SDL_EVDEV_GuessDeviceClass(const unsigned long bitmask_ev[NBITS(EV_MAX)],
const unsigned long bitmask_abs[NBITS(ABS_MAX)],
const unsigned long bitmask_key[NBITS(KEY_MAX)],
const unsigned long bitmask_rel[NBITS(REL_MAX)]);
#endif /* HAVE_LINUX_INPUT_H */

View File

@@ -218,7 +218,7 @@ static void kbd_cleanup(void)
static void SDL_EVDEV_kbd_reraise_signal(int sig)
{
raise(sig);
(void)raise(sig);
}
siginfo_t *SDL_EVDEV_kdb_cleanup_siginfo = NULL;
@@ -303,7 +303,7 @@ static void kbd_register_emerg_cleanup(SDL_EVDEV_keyboard_state *kbd)
* functions that are called when the shared library is unloaded.
* -- man atexit(3)
*/
atexit(kbd_cleanup_atexit);
(void)atexit(kbd_cleanup_atexit);
kbd_cleanup_atexit_installed = 1;
}
@@ -407,33 +407,33 @@ SDL_EVDEV_kbd_init(void)
return kbd;
}
void SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *kbd)
void SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *state)
{
if (kbd == NULL) {
if (state == NULL) {
return;
}
kbd_unregister_emerg_cleanup();
if (kbd->console_fd >= 0) {
if (state->console_fd >= 0) {
/* Restore the original keyboard mode */
ioctl(kbd->console_fd, KDSKBMODE, kbd->old_kbd_mode);
ioctl(state->console_fd, KDSKBMODE, state->old_kbd_mode);
close(kbd->console_fd);
kbd->console_fd = -1;
close(state->console_fd);
state->console_fd = -1;
}
if (kbd->key_maps && kbd->key_maps != default_key_maps) {
if (state->key_maps && state->key_maps != default_key_maps) {
int i;
for (i = 0; i < MAX_NR_KEYMAPS; ++i) {
if (kbd->key_maps[i]) {
SDL_free(kbd->key_maps[i]);
if (state->key_maps[i]) {
SDL_free(state->key_maps[i]);
}
}
SDL_free(kbd->key_maps);
SDL_free(state->key_maps);
}
SDL_free(kbd);
SDL_free(state);
}
/*
@@ -449,10 +449,9 @@ static void put_queue(SDL_EVDEV_keyboard_state *kbd, uint c)
static void put_utf8(SDL_EVDEV_keyboard_state *kbd, uint c)
{
if (c < 0x80)
/* 0******* */
put_queue(kbd, c);
else if (c < 0x800) {
if (c < 0x80) {
put_queue(kbd, c); /* 0******* */
} else if (c < 0x800) {
/* 110***** 10****** */
put_queue(kbd, 0xc0 | (c >> 6));
put_queue(kbd, 0x80 | (c & 0x3f));
@@ -626,8 +625,9 @@ static void k_self(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_f
static void k_deadunicode(SDL_EVDEV_keyboard_state *kbd, unsigned int value, char up_flag)
{
if (up_flag)
if (up_flag) {
return;
}
kbd->diacr = (kbd->diacr ? handle_diacr(kbd, value) : value);
}
@@ -660,8 +660,9 @@ static void k_pad(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_fl
{
static const char pad_chars[] = "0123456789+-*/\015,.?()#";
if (up_flag)
if (up_flag) {
return; /* no action, if this is a key release */
}
if (!vc_kbd_led(kbd, K_NUMLOCK)) {
/* unprintable action */
@@ -675,8 +676,9 @@ static void k_shift(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_
{
int old_state = kbd->shift_state;
if (kbd->rep)
if (kbd->rep) {
return;
}
/*
* Mimic typewriter:
* a CapsShift key acts like Shift but undoes CapsLock
@@ -696,13 +698,15 @@ static void k_shift(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_
if (kbd->shift_down[value]) {
kbd->shift_down[value]--;
}
} else
} else {
kbd->shift_down[value]++;
}
if (kbd->shift_down[value])
if (kbd->shift_down[value]) {
kbd->shift_state |= (1 << value);
else
} else {
kbd->shift_state &= ~(1 << value);
}
/* kludge */
if (up_flag && kbd->shift_state != old_state && kbd->npadch != -1) {
@@ -719,8 +723,9 @@ static void k_ascii(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_
{
int base;
if (up_flag)
if (up_flag) {
return;
}
if (value < 10) {
/* decimal input of code, while Alt depressed */
@@ -731,16 +736,18 @@ static void k_ascii(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_
base = 16;
}
if (kbd->npadch == -1)
if (kbd->npadch == -1) {
kbd->npadch = value;
else
} else {
kbd->npadch = kbd->npadch * base + value;
}
}
static void k_lock(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_flag)
{
if (up_flag || kbd->rep)
if (up_flag || kbd->rep) {
return;
}
chg_vc_kbd_lock(kbd, value);
}
@@ -748,8 +755,9 @@ static void k_lock(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_f
static void k_slock(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_flag)
{
k_shift(kbd, value, up_flag);
if (up_flag || kbd->rep)
if (up_flag || kbd->rep) {
return;
}
chg_vc_kbd_slock(kbd, value);
/* try to make Alt, oops, AltGr and such work */
@@ -763,26 +771,26 @@ static void k_brl(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_fl
{
}
void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *kbd, unsigned int keycode, int down)
void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *state, unsigned int keycode, int down)
{
unsigned char shift_final;
unsigned char type;
unsigned short *key_map;
unsigned short keysym;
if (kbd == NULL) {
if (state == NULL) {
return;
}
kbd->rep = (down == 2);
state->rep = (down == 2);
shift_final = (kbd->shift_state | kbd->slockstate) ^ kbd->lockstate;
key_map = kbd->key_maps[shift_final];
shift_final = (state->shift_state | state->slockstate) ^ state->lockstate;
key_map = state->key_maps[shift_final];
if (key_map == NULL) {
/* Unsupported shift state (e.g. ctrl = 4, alt = 8), just reset to the default state */
kbd->shift_state = 0;
kbd->slockstate = 0;
kbd->lockstate = 0;
state->shift_state = 0;
state->slockstate = 0;
state->lockstate = 0;
return;
}
@@ -796,7 +804,7 @@ void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *kbd, unsigned int keycode,
if (type < 0xf0) {
if (down) {
put_utf8(kbd, keysym);
put_utf8(state, keysym);
}
} else {
type -= 0xf0;
@@ -805,25 +813,25 @@ void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *kbd, unsigned int keycode,
if (type == KT_LETTER) {
type = KT_LATIN;
if (vc_kbd_led(kbd, K_CAPSLOCK)) {
key_map = kbd->key_maps[shift_final ^ (1 << KG_SHIFT)];
if (vc_kbd_led(state, K_CAPSLOCK)) {
key_map = state->key_maps[shift_final ^ (1 << KG_SHIFT)];
if (key_map) {
keysym = key_map[keycode];
}
}
}
(*k_handler[type])(kbd, keysym & 0xff, !down);
(*k_handler[type])(state, keysym & 0xff, !down);
if (type != KT_SLOCK) {
kbd->slockstate = 0;
state->slockstate = 0;
}
}
if (kbd->text_len > 0) {
kbd->text[kbd->text_len] = '\0';
SDL_SendKeyboardText(kbd->text);
kbd->text_len = 0;
if (state->text_len > 0) {
state->text[state->text_len] = '\0';
SDL_SendKeyboardText(state->text);
state->text_len = 0;
}
}

View File

@@ -64,9 +64,9 @@ static char *GetAppName()
int linksize;
#if defined(__LINUX__)
SDL_snprintf(procfile, sizeof(procfile), "/proc/%d/exe", getpid());
(void)SDL_snprintf(procfile, sizeof procfile, "/proc/%d/exe", getpid());
#elif defined(__FREEBSD__)
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) {

View File

@@ -324,7 +324,7 @@ static char *IBus_ReadAddressFromFile(const char *file_path)
}
}
fclose(addr_file);
(void)fclose(addr_file);
if (success) {
return SDL_strdup(addr_buf + (sizeof("IBUS_ADDRESS=") - 1));
@@ -407,14 +407,14 @@ static char *IBus_GetDBusAddressFilename(void)
SDL_free(display);
return NULL;
}
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));
SDL_snprintf(file_path, sizeof(file_path), "%s/ibus/bus/%s-%s-%s",
config_dir, key, host, disp_num);
(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);
@@ -488,7 +488,7 @@ static SDL_bool IBus_SetupConnection(SDL_DBusContext *dbus, const char *addr)
if (result) {
char matchstr[128];
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);

View File

@@ -268,10 +268,10 @@ WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid)
}
ptr = (const unsigned char *)guid;
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]);
(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]);
strw = WIN_UTF8ToString(keystr);
rc = (RegOpenKeyExW(HKEY_LOCAL_MACHINE, strw, 0, KEY_QUERY_VALUE, &hkey) == ERROR_SUCCESS);