Skip to content

Commit 49774b9

Browse files
committed
Use SDL_bool instead an int return code in the SDL API
Most SDL functions used to indicate success or failure using an int return code. These functions have been changed to return SDL_bool. Here is a coccinelle patch to change code that previously compared the return value to 0 and changes it to a boolean test: @ bool_return_type @ identifier func =~ "^(Mix_FadeInMusic|Mix_FadeInMusicPos|Mix_GroupChannels|Mix_ModMusicJumpToOrder|Mix_OpenAudio|Mix_PlayMusic|Mix_SetMusicCMD|Mix_SetMusicPosition|Mix_SetSoundFonts|Mix_StartTrack)$"; @@ ( func( ... ) - == 0 | - func( + !func( ... ) - < 0 | - func( + !func( ... ) - != 0 | - func( + !func( ... ) - == -1 )
1 parent 46ad68a commit 49774b9

29 files changed

+370
-483
lines changed

cmake/test/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ int main(int argc, char *argv[])
99
return 1;
1010
}
1111
if (Mix_Init(0) == 0) {
12-
SDL_Log("Mix_Init: no sound/music loaders supported (%s)\n", Mix_GetError());
12+
SDL_Log("Mix_Init: no sound/music loaders supported (%s)\n", SDL_GetError());
1313
}
1414
Mix_Quit();
1515
SDL_Quit();

examples/playmus.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ int main(int argc, char *argv[])
189189
#endif
190190

191191
/* Open the audio device */
192-
if (Mix_OpenAudio(0, &spec) < 0) {
192+
if (!Mix_OpenAudio(0, &spec)) {
193193
SDL_Log("Couldn't open audio: %s\n", SDL_GetError());
194194
return 2;
195195
} else {

examples/playwave.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ static void do_panning_update(void)
169169
if (!panningok) {
170170
SDL_Log("Mix_SetPanning(0, %d, %d) failed!\n",
171171
(int) leftvol, (int) rightvol);
172-
SDL_Log("Reason: [%s].\n", Mix_GetError());
172+
SDL_Log("Reason: [%s].\n", SDL_GetError());
173173
}
174174

175175
if ((leftvol == 255) || (leftvol == 0)) {
@@ -206,7 +206,7 @@ static void do_distance_update(void)
206206
distanceok = Mix_SetDistance(0, distance);
207207
if (!distanceok) {
208208
SDL_Log("Mix_SetDistance(0, %d) failed!\n", (int) distance);
209-
SDL_Log("Reason: [%s].\n", Mix_GetError());
209+
SDL_Log("Reason: [%s].\n", SDL_GetError());
210210
}
211211

212212
if (distance == 0) {
@@ -240,7 +240,7 @@ static void do_position_update(void)
240240
if (!positionok) {
241241
SDL_Log("Mix_SetPosition(0, %d, %d) failed!\n",
242242
(int) angle, (int) distance);
243-
SDL_Log("Reason: [%s].\n", Mix_GetError());
243+
SDL_Log("Reason: [%s].\n", SDL_GetError());
244244
}
245245

246246
if (angle == 0) {
@@ -424,7 +424,7 @@ int main(int argc, char *argv[])
424424
#endif
425425

426426
/* Open the audio device */
427-
if (Mix_OpenAudio(0, &spec) < 0) {
427+
if (!Mix_OpenAudio(0, &spec)) {
428428
SDL_Log("Couldn't open audio: %s\n", SDL_GetError());
429429
CleanUp(2);
430430
} else {
@@ -469,7 +469,7 @@ int main(int argc, char *argv[])
469469
(reverse_stereo))
470470
{
471471
SDL_Log("Failed to set up reverse stereo effect!\n");
472-
SDL_Log("Reason: [%s].\n", Mix_GetError());
472+
SDL_Log("Reason: [%s].\n", SDL_GetError());
473473
}
474474

475475
/* Play and then exit */

0 commit comments

Comments
 (0)