Make SDL_SetError and friends unconditionally return -1.

This lets us change things like this...

    if (Failed) {
        SDL_SetError("We failed");
        return -1;
    }

...into this...

    if (Failed) {
        return SDL_SetError("We failed");
    }


 Fixes Bugzilla #1778.
This commit is contained in:
Ryan C. Gordon 2013-03-31 12:48:50 -04:00
parent 8c6b9f4743
commit 4f438b70a2
106 changed files with 616 additions and 1189 deletions

View file

@ -244,8 +244,7 @@ SDL_PeepEvents(SDL_Event * events, int numevents, SDL_eventaction action,
}
SDL_UnlockMutex(SDL_EventQ.lock);
} else {
SDL_SetError("Couldn't lock event queue");
used = -1;
return SDL_SetError("Couldn't lock event queue");
}
return (used);
}

View file

@ -158,8 +158,7 @@ int SDL_SaveDollarTemplate(SDL_GestureID gestureId, SDL_RWops *src)
}
}
}
SDL_SetError("Unknown gestureId");
return -1;
return SDL_SetError("Unknown gestureId");
}
//path is an already sampled set of points
@ -176,8 +175,7 @@ static int SDL_AddDollarGesture_one(SDL_GestureTouch* inTouch, SDL_FloatPoint* p
(index + 1) *
sizeof(SDL_DollarTemplate));
if (!dollarTemplate) {
SDL_OutOfMemory();
return -1;
return SDL_OutOfMemory();
}
inTouch->dollarTemplate = dollarTemplate;
@ -419,8 +417,7 @@ int SDL_GestureAddTouch(SDL_TouchID touchId)
sizeof(SDL_GestureTouch));
if (!gestureTouch) {
SDL_OutOfMemory();
return -1;
return SDL_OutOfMemory();
}
SDL_gestureTouch = gestureTouch;

View file

@ -413,8 +413,7 @@ SDL_SetRelativeMouseMode(SDL_bool enabled)
}
if (!mouse->SetRelativeMouseMode) {
SDL_Unsupported();
return -1;
return SDL_Unsupported();
}
if (mouse->SetRelativeMouseMode(enabled) < 0) {

View file

@ -141,8 +141,7 @@ SDL_AddTouch(SDL_TouchID touchID, const char *name)
touchDevices = (SDL_Touch **) SDL_realloc(SDL_touchDevices,
(SDL_num_touch + 1) * sizeof(*touchDevices));
if (!touchDevices) {
SDL_OutOfMemory();
return -1;
return SDL_OutOfMemory();
}
SDL_touchDevices = touchDevices;
@ -150,8 +149,7 @@ SDL_AddTouch(SDL_TouchID touchID, const char *name)
SDL_touchDevices[index] = (SDL_Touch *) SDL_malloc(sizeof(*SDL_touchDevices[index]));
if (!SDL_touchDevices[index]) {
SDL_OutOfMemory();
return -1;
return SDL_OutOfMemory();
}
/* we're setting the touch properties */
@ -176,14 +174,12 @@ SDL_AddFinger(SDL_Touch *touch, SDL_FingerID fingerid, float x, float y, float p
SDL_Finger **new_fingers;
new_fingers = (SDL_Finger **)SDL_realloc(touch->fingers, (touch->max_fingers+1)*sizeof(*touch->fingers));
if (!new_fingers) {
SDL_OutOfMemory();
return -1;
return SDL_OutOfMemory();
}
touch->fingers = new_fingers;
touch->fingers[touch->max_fingers] = (SDL_Finger *)SDL_malloc(sizeof(*finger));
if (!touch->fingers[touch->max_fingers]) {
SDL_OutOfMemory();
return -1;
return SDL_OutOfMemory();
}
touch->max_fingers++;
}