mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-31 17:07:39 +00:00
Fixed most small problems reported by cppcheck for src/core PR #7307 (from @kevin2kevin2)
This commit is contained in:
parent
bcd97b36d2
commit
b44d3699b1
6 changed files with 15 additions and 18 deletions
|
@ -772,11 +772,10 @@ JNIEXPORT int JNICALL SDL_JAVA_INTERFACE(nativeRunMain)(JNIEnv *env, jclass cls,
|
||||||
*/
|
*/
|
||||||
argv[argc++] = SDL_strdup("app_process");
|
argv[argc++] = SDL_strdup("app_process");
|
||||||
for (i = 0; i < len; ++i) {
|
for (i = 0; i < len; ++i) {
|
||||||
const char *utf;
|
|
||||||
char *arg = NULL;
|
char *arg = NULL;
|
||||||
jstring string = (*env)->GetObjectArrayElement(env, array, i);
|
jstring string = (*env)->GetObjectArrayElement(env, array, i);
|
||||||
if (string) {
|
if (string) {
|
||||||
utf = (*env)->GetStringUTFChars(env, string, 0);
|
const char *utf = (*env)->GetStringUTFChars(env, string, 0);
|
||||||
if (utf) {
|
if (utf) {
|
||||||
arg = SDL_strdup(utf);
|
arg = SDL_strdup(utf);
|
||||||
(*env)->ReleaseStringUTFChars(env, string, utf);
|
(*env)->ReleaseStringUTFChars(env, string, utf);
|
||||||
|
@ -1444,10 +1443,10 @@ SDL_bool Android_JNI_ShouldMinimizeOnFocusLoss()
|
||||||
|
|
||||||
SDL_bool Android_JNI_GetAccelerometerValues(float values[3])
|
SDL_bool Android_JNI_GetAccelerometerValues(float values[3])
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
SDL_bool retval = SDL_FALSE;
|
SDL_bool retval = SDL_FALSE;
|
||||||
|
|
||||||
if (bHasNewData) {
|
if (bHasNewData) {
|
||||||
|
int i;
|
||||||
for (i = 0; i < 3; ++i) {
|
for (i = 0; i < 3; ++i) {
|
||||||
values[i] = fLastAccelerometer[i];
|
values[i] = fLastAccelerometer[i];
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,7 +135,7 @@ static void kbd_cleanup_signal_action(int signum, siginfo_t *info, void *ucontex
|
||||||
|
|
||||||
static void kbd_unregister_emerg_cleanup()
|
static void kbd_unregister_emerg_cleanup()
|
||||||
{
|
{
|
||||||
int tabidx, signum;
|
int tabidx;
|
||||||
|
|
||||||
kbd_cleanup_state = NULL;
|
kbd_cleanup_state = NULL;
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ static void kbd_unregister_emerg_cleanup()
|
||||||
for (tabidx = 0; tabidx < sizeof(fatal_signals) / sizeof(fatal_signals[0]); ++tabidx) {
|
for (tabidx = 0; tabidx < sizeof(fatal_signals) / sizeof(fatal_signals[0]); ++tabidx) {
|
||||||
struct sigaction *old_action_p;
|
struct sigaction *old_action_p;
|
||||||
struct sigaction cur_action;
|
struct sigaction cur_action;
|
||||||
signum = fatal_signals[tabidx];
|
int signum = fatal_signals[tabidx];
|
||||||
old_action_p = &(old_sigaction[signum]);
|
old_action_p = &(old_sigaction[signum]);
|
||||||
|
|
||||||
/* Examine current signal action */
|
/* Examine current signal action */
|
||||||
|
@ -176,7 +176,7 @@ static void kbd_cleanup_atexit(void)
|
||||||
|
|
||||||
static void kbd_register_emerg_cleanup(SDL_EVDEV_keyboard_state *kbd)
|
static void kbd_register_emerg_cleanup(SDL_EVDEV_keyboard_state *kbd)
|
||||||
{
|
{
|
||||||
int tabidx, signum;
|
int tabidx;
|
||||||
|
|
||||||
if (kbd_cleanup_state != NULL) {
|
if (kbd_cleanup_state != NULL) {
|
||||||
return;
|
return;
|
||||||
|
@ -200,7 +200,7 @@ static void kbd_register_emerg_cleanup(SDL_EVDEV_keyboard_state *kbd)
|
||||||
for (tabidx = 0; tabidx < sizeof(fatal_signals) / sizeof(fatal_signals[0]); ++tabidx) {
|
for (tabidx = 0; tabidx < sizeof(fatal_signals) / sizeof(fatal_signals[0]); ++tabidx) {
|
||||||
struct sigaction *old_action_p;
|
struct sigaction *old_action_p;
|
||||||
struct sigaction new_action;
|
struct sigaction new_action;
|
||||||
signum = fatal_signals[tabidx];
|
int signum = fatal_signals[tabidx];
|
||||||
old_action_p = &(old_sigaction[signum]);
|
old_action_p = &(old_sigaction[signum]);
|
||||||
if (sigaction(signum, NULL, old_action_p)) {
|
if (sigaction(signum, NULL, old_action_p)) {
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -782,7 +782,6 @@ static void SDL_EVDEV_sync_device(SDL_evdevlist_item *item)
|
||||||
|
|
||||||
static int SDL_EVDEV_device_added(const char *dev_path, int udev_class)
|
static int SDL_EVDEV_device_added(const char *dev_path, int udev_class)
|
||||||
{
|
{
|
||||||
int ret;
|
|
||||||
SDL_evdevlist_item *item;
|
SDL_evdevlist_item *item;
|
||||||
unsigned long relbit[NBITS(REL_MAX)] = { 0 };
|
unsigned long relbit[NBITS(REL_MAX)] = { 0 };
|
||||||
|
|
||||||
|
@ -819,6 +818,7 @@ static int SDL_EVDEV_device_added(const char *dev_path, int udev_class)
|
||||||
|
|
||||||
/* For now, we just treat a touchpad like a touchscreen */
|
/* For now, we just treat a touchpad like a touchscreen */
|
||||||
if (udev_class & (SDL_UDEV_DEVICE_TOUCHSCREEN | SDL_UDEV_DEVICE_TOUCHPAD)) {
|
if (udev_class & (SDL_UDEV_DEVICE_TOUCHSCREEN | SDL_UDEV_DEVICE_TOUCHPAD)) {
|
||||||
|
int ret;
|
||||||
item->is_touchscreen = SDL_TRUE;
|
item->is_touchscreen = SDL_TRUE;
|
||||||
ret = SDL_EVDEV_init_touchscreen(item, udev_class);
|
ret = SDL_EVDEV_init_touchscreen(item, udev_class);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
|
|
@ -249,7 +249,7 @@ static void kbd_cleanup_signal_action(int signum, siginfo_t *info, void *ucontex
|
||||||
|
|
||||||
static void kbd_unregister_emerg_cleanup()
|
static void kbd_unregister_emerg_cleanup()
|
||||||
{
|
{
|
||||||
int tabidx, signum;
|
int tabidx;
|
||||||
|
|
||||||
kbd_cleanup_state = NULL;
|
kbd_cleanup_state = NULL;
|
||||||
|
|
||||||
|
@ -261,7 +261,7 @@ static void kbd_unregister_emerg_cleanup()
|
||||||
for (tabidx = 0; tabidx < sizeof(fatal_signals) / sizeof(fatal_signals[0]); ++tabidx) {
|
for (tabidx = 0; tabidx < sizeof(fatal_signals) / sizeof(fatal_signals[0]); ++tabidx) {
|
||||||
struct sigaction *old_action_p;
|
struct sigaction *old_action_p;
|
||||||
struct sigaction cur_action;
|
struct sigaction cur_action;
|
||||||
signum = fatal_signals[tabidx];
|
int signum = fatal_signals[tabidx];
|
||||||
old_action_p = &(old_sigaction[signum]);
|
old_action_p = &(old_sigaction[signum]);
|
||||||
|
|
||||||
/* Examine current signal action */
|
/* Examine current signal action */
|
||||||
|
@ -290,7 +290,7 @@ static void kbd_cleanup_atexit(void)
|
||||||
|
|
||||||
static void kbd_register_emerg_cleanup(SDL_EVDEV_keyboard_state *kbd)
|
static void kbd_register_emerg_cleanup(SDL_EVDEV_keyboard_state *kbd)
|
||||||
{
|
{
|
||||||
int tabidx, signum;
|
int tabidx;
|
||||||
|
|
||||||
if (kbd_cleanup_state != NULL) {
|
if (kbd_cleanup_state != NULL) {
|
||||||
return;
|
return;
|
||||||
|
@ -314,7 +314,7 @@ static void kbd_register_emerg_cleanup(SDL_EVDEV_keyboard_state *kbd)
|
||||||
for (tabidx = 0; tabidx < sizeof(fatal_signals) / sizeof(fatal_signals[0]); ++tabidx) {
|
for (tabidx = 0; tabidx < sizeof(fatal_signals) / sizeof(fatal_signals[0]); ++tabidx) {
|
||||||
struct sigaction *old_action_p;
|
struct sigaction *old_action_p;
|
||||||
struct sigaction new_action;
|
struct sigaction new_action;
|
||||||
signum = fatal_signals[tabidx];
|
int signum = fatal_signals[tabidx];
|
||||||
old_action_p = &(old_sigaction[signum]);
|
old_action_p = &(old_sigaction[signum]);
|
||||||
if (sigaction(signum, NULL, old_action_p)) {
|
if (sigaction(signum, NULL, old_action_p)) {
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -152,8 +152,6 @@ int SDL_UDEV_Init(void)
|
||||||
|
|
||||||
void SDL_UDEV_Quit(void)
|
void SDL_UDEV_Quit(void)
|
||||||
{
|
{
|
||||||
SDL_UDEV_CallbackList *item;
|
|
||||||
|
|
||||||
if (_this == NULL) {
|
if (_this == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -173,7 +171,7 @@ void SDL_UDEV_Quit(void)
|
||||||
|
|
||||||
/* Remove existing devices */
|
/* Remove existing devices */
|
||||||
while (_this->first != NULL) {
|
while (_this->first != NULL) {
|
||||||
item = _this->first;
|
SDL_UDEV_CallbackList *item = _this->first;
|
||||||
_this->first = _this->first->next;
|
_this->first = _this->first->next;
|
||||||
SDL_free(item);
|
SDL_free(item);
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,14 +61,14 @@ SDL_WSCONS_mouse_input_data *SDL_WSCONS_Init_Mouse()
|
||||||
void updateMouse(SDL_WSCONS_mouse_input_data *inputData)
|
void updateMouse(SDL_WSCONS_mouse_input_data *inputData)
|
||||||
{
|
{
|
||||||
struct wscons_event events[64];
|
struct wscons_event events[64];
|
||||||
int type;
|
int n;
|
||||||
int n, i;
|
|
||||||
SDL_Mouse *mouse = SDL_GetMouse();
|
SDL_Mouse *mouse = SDL_GetMouse();
|
||||||
|
|
||||||
if ((n = read(inputData->fd, events, sizeof(events))) > 0) {
|
if ((n = read(inputData->fd, events, sizeof(events))) > 0) {
|
||||||
|
int i;
|
||||||
n /= sizeof(struct wscons_event);
|
n /= sizeof(struct wscons_event);
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
type = events[i].type;
|
int type = events[i].type;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case WSCONS_EVENT_MOUSE_DOWN:
|
case WSCONS_EVENT_MOUSE_DOWN:
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue