Fixed most small problems reported by cppcheck
for src/core
The following command was used: ``` cppcheck \ --verbose --quiet --error-exitcode=1 --force \ --enable=warning,style,performance,portability \ src/core/ ```
This commit is contained in:
parent
adf31f6ec0
commit
a92209d53e
|
@ -766,10 +766,10 @@ JNIEXPORT int JNICALL SDL_JAVA_INTERFACE(nativeRunMain)(JNIEnv *env, jclass cls,
|
|||
*/
|
||||
argv[argc++] = SDL_strdup("app_process");
|
||||
for (i = 0; i < len; ++i) {
|
||||
const char *utf;
|
||||
char *arg = NULL;
|
||||
jstring string = (*env)->GetObjectArrayElement(env, array, i);
|
||||
if (string) {
|
||||
const char *utf;
|
||||
utf = (*env)->GetStringUTFChars(env, string, 0);
|
||||
if (utf) {
|
||||
arg = SDL_strdup(utf);
|
||||
|
@ -1420,10 +1420,10 @@ SDL_bool Android_JNI_ShouldMinimizeOnFocusLoss()
|
|||
|
||||
SDL_bool Android_JNI_GetAccelerometerValues(float values[3])
|
||||
{
|
||||
int i;
|
||||
SDL_bool retval = SDL_FALSE;
|
||||
|
||||
if (bHasNewData) {
|
||||
int i;
|
||||
for (i = 0; i < 3; ++i) {
|
||||
values[i] = fLastAccelerometer[i];
|
||||
}
|
||||
|
|
|
@ -136,7 +136,7 @@ static void kbd_cleanup_signal_action(int signum, siginfo_t* info, void* ucontex
|
|||
|
||||
static void kbd_unregister_emerg_cleanup()
|
||||
{
|
||||
int tabidx, signum;
|
||||
int tabidx;
|
||||
|
||||
kbd_cleanup_state = NULL;
|
||||
|
||||
|
@ -146,6 +146,7 @@ static void kbd_unregister_emerg_cleanup()
|
|||
kbd_cleanup_sigactions_installed = 0;
|
||||
|
||||
for (tabidx = 0; tabidx < sizeof(fatal_signals) / sizeof(fatal_signals[0]); ++tabidx) {
|
||||
int signum;
|
||||
struct sigaction* old_action_p;
|
||||
struct sigaction cur_action;
|
||||
signum = fatal_signals[tabidx];
|
||||
|
@ -176,7 +177,7 @@ static void kbd_cleanup_atexit(void)
|
|||
|
||||
static void kbd_register_emerg_cleanup(SDL_EVDEV_keyboard_state * kbd)
|
||||
{
|
||||
int tabidx, signum;
|
||||
int tabidx;
|
||||
|
||||
if (kbd_cleanup_state != NULL) {
|
||||
return;
|
||||
|
@ -198,6 +199,7 @@ static void kbd_register_emerg_cleanup(SDL_EVDEV_keyboard_state * kbd)
|
|||
kbd_cleanup_sigactions_installed = 1;
|
||||
|
||||
for (tabidx = 0; tabidx < sizeof(fatal_signals) / sizeof(fatal_signals[0]); ++tabidx) {
|
||||
int signum;
|
||||
struct sigaction* old_action_p;
|
||||
struct sigaction new_action;
|
||||
signum = fatal_signals[tabidx];
|
||||
|
@ -475,12 +477,12 @@ SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *kbd, unsigned int keycode, int d
|
|||
unsigned int final_key_state;
|
||||
unsigned int map_from_key_sym;
|
||||
|
||||
key_map = *kbd->key_map;
|
||||
|
||||
if (!kbd) {
|
||||
return;
|
||||
}
|
||||
|
||||
key_map = *kbd->key_map;
|
||||
|
||||
kbd->rep = (down == 2);
|
||||
|
||||
if (keycode < NUM_KEYS) {
|
||||
|
|
|
@ -767,7 +767,6 @@ SDL_EVDEV_sync_device(SDL_evdevlist_item *item)
|
|||
static int
|
||||
SDL_EVDEV_device_added(const char *dev_path, int udev_class)
|
||||
{
|
||||
int ret;
|
||||
SDL_evdevlist_item *item;
|
||||
unsigned long relbit[NBITS(REL_MAX)] = { 0 };
|
||||
|
||||
|
@ -806,6 +805,7 @@ SDL_EVDEV_device_added(const char *dev_path, int udev_class)
|
|||
if (udev_class & (SDL_UDEV_DEVICE_TOUCHSCREEN | SDL_UDEV_DEVICE_TOUCHPAD)) {
|
||||
item->is_touchscreen = SDL_TRUE;
|
||||
|
||||
int ret;
|
||||
if ((ret = SDL_EVDEV_init_touchscreen(item, udev_class)) < 0) {
|
||||
close(item->fd);
|
||||
SDL_free(item->path);
|
||||
|
|
|
@ -254,7 +254,7 @@ static void kbd_cleanup_signal_action(int signum, siginfo_t* info, void* ucontex
|
|||
|
||||
static void kbd_unregister_emerg_cleanup()
|
||||
{
|
||||
int tabidx, signum;
|
||||
int tabidx;
|
||||
|
||||
kbd_cleanup_state = NULL;
|
||||
|
||||
|
@ -264,6 +264,7 @@ static void kbd_unregister_emerg_cleanup()
|
|||
kbd_cleanup_sigactions_installed = 0;
|
||||
|
||||
for (tabidx = 0; tabidx < sizeof(fatal_signals) / sizeof(fatal_signals[0]); ++tabidx) {
|
||||
int signum;
|
||||
struct sigaction* old_action_p;
|
||||
struct sigaction cur_action;
|
||||
signum = fatal_signals[tabidx];
|
||||
|
@ -294,7 +295,7 @@ static void kbd_cleanup_atexit(void)
|
|||
|
||||
static void kbd_register_emerg_cleanup(SDL_EVDEV_keyboard_state * kbd)
|
||||
{
|
||||
int tabidx, signum;
|
||||
int tabidx;
|
||||
|
||||
if (kbd_cleanup_state != NULL) {
|
||||
return;
|
||||
|
@ -316,6 +317,7 @@ static void kbd_register_emerg_cleanup(SDL_EVDEV_keyboard_state * kbd)
|
|||
kbd_cleanup_sigactions_installed = 1;
|
||||
|
||||
for (tabidx = 0; tabidx < sizeof(fatal_signals) / sizeof(fatal_signals[0]); ++tabidx) {
|
||||
int signum;
|
||||
struct sigaction* old_action_p;
|
||||
struct sigaction new_action;
|
||||
signum = fatal_signals[tabidx];
|
||||
|
|
|
@ -302,6 +302,8 @@ SDL_LinuxSetThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int schedP
|
|||
#if SDL_THREADS_DISABLED
|
||||
return SDL_Unsupported();
|
||||
#else
|
||||
|
||||
#if SDL_USE_LIBDBUS
|
||||
int osPriority;
|
||||
|
||||
if (schedPolicy == SCHED_RR || schedPolicy == SCHED_FIFO) {
|
||||
|
@ -330,7 +332,6 @@ SDL_LinuxSetThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int schedP
|
|||
}
|
||||
}
|
||||
|
||||
#if SDL_USE_LIBDBUS
|
||||
/* Note that this fails you most likely:
|
||||
* Have your process's scheduler incorrectly configured.
|
||||
See the requirements at:
|
||||
|
|
|
@ -162,8 +162,6 @@ SDL_UDEV_Init(void)
|
|||
void
|
||||
SDL_UDEV_Quit(void)
|
||||
{
|
||||
SDL_UDEV_CallbackList *item;
|
||||
|
||||
if (_this == NULL) {
|
||||
return;
|
||||
}
|
||||
|
@ -183,6 +181,7 @@ SDL_UDEV_Quit(void)
|
|||
|
||||
/* Remove existing devices */
|
||||
while (_this->first != NULL) {
|
||||
SDL_UDEV_CallbackList *item;
|
||||
item = _this->first;
|
||||
_this->first = _this->first->next;
|
||||
SDL_free(item);
|
||||
|
|
|
@ -57,15 +57,16 @@ SDL_WSCONS_mouse_input_data* SDL_WSCONS_Init_Mouse()
|
|||
void updateMouse(SDL_WSCONS_mouse_input_data* inputData)
|
||||
{
|
||||
struct wscons_event events[64];
|
||||
int type;
|
||||
int n,i;
|
||||
int n;
|
||||
SDL_Mouse* mouse = SDL_GetMouse();
|
||||
|
||||
if ((n = read(inputData->fd, events, sizeof(events))) > 0)
|
||||
{
|
||||
int i;
|
||||
n /= sizeof(struct wscons_event);
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
int type;
|
||||
type = events[i].type;
|
||||
switch(type)
|
||||
{
|
||||
|
|
|
@ -72,13 +72,13 @@ typedef struct iuconv_obj {
|
|||
static int _createUconvObj(const char *code, UconvObject *uobj)
|
||||
{
|
||||
UniChar uc_code[MAX_CP_NAME_LEN];
|
||||
int i;
|
||||
const unsigned char *ch =
|
||||
(const unsigned char *)code;
|
||||
|
||||
if (code == NULL)
|
||||
uc_code[0] = 0;
|
||||
else {
|
||||
int i;
|
||||
for (i = 0; i < MAX_CP_NAME_LEN; i++) {
|
||||
uc_code[i] = (unsigned short)*ch;
|
||||
if (! (*ch))
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
|
||||
int StrUTF8(int to_utf8, char *dst, int c_dst, char *src, int c_src)
|
||||
{
|
||||
size_t rc;
|
||||
char *dststart = dst;
|
||||
iconv_t cd;
|
||||
char *tocp, *fromcp;
|
||||
|
@ -56,6 +55,7 @@ int StrUTF8(int to_utf8, char *dst, int c_dst, char *src, int c_src)
|
|||
}
|
||||
|
||||
while (c_src > 0) {
|
||||
size_t rc;
|
||||
rc = iconv(cd, &src, (size_t *)&c_src, &dst, (size_t *)&c_dst);
|
||||
if (rc == (size_t)-1) {
|
||||
if (errno == EILSEQ) {
|
||||
|
|
Loading…
Reference in a new issue