From 5c212cb0c5d43f4fd80a6e7d900436e870435165 Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Thu, 10 Dec 2020 12:24:24 +0300 Subject: [PATCH] remove a few stale NULL message/title checks after commit e2b729b1756a top-level guarantees non-NULL message / title passed in messageboxdata --- src/video/cocoa/SDL_cocoamessagebox.m | 6 +++--- src/video/haiku/SDL_bmessagebox.cc | 4 ++-- src/video/windows/SDL_windowsmessagebox.c | 2 +- src/video/x11/SDL_x11messagebox.c | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/video/cocoa/SDL_cocoamessagebox.m b/src/video/cocoa/SDL_cocoamessagebox.m index 173225b2c..91a5660ef 100644 --- a/src/video/cocoa/SDL_cocoamessagebox.m +++ b/src/video/cocoa/SDL_cocoamessagebox.m @@ -113,7 +113,7 @@ Cocoa_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) int i; for (i = 0; i < messageboxdata->numbuttons; ++i) { const SDL_MessageBoxButtonData *sdlButton; - NSButton *button; + NSButton *button; if (messageboxdata->flags & SDL_MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT) { sdlButton = &messageboxdata->buttons[messageboxdata->numbuttons - 1 - i]; @@ -142,8 +142,8 @@ Cocoa_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) if (clicked >= NSAlertFirstButtonReturn) { clicked -= NSAlertFirstButtonReturn; if (messageboxdata->flags & SDL_MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT) { - clicked = messageboxdata->numbuttons - 1 - clicked; - } + clicked = messageboxdata->numbuttons - 1 - clicked; + } *buttonid = buttons[clicked].buttonid; } else { returnValue = SDL_SetError("Did not get a valid `clicked button' id: %ld", (long)clicked); diff --git a/src/video/haiku/SDL_bmessagebox.cc b/src/video/haiku/SDL_bmessagebox.cc index c7ec2063f..781002f41 100644 --- a/src/video/haiku/SDL_bmessagebox.cc +++ b/src/video/haiku/SDL_bmessagebox.cc @@ -154,9 +154,9 @@ class HAIKU_SDL_MessageBox : public BAlert ApplyAndParseColorScheme(aMessageBoxData->colorScheme); } - (aMessageBoxData->title && aMessageBoxData->title[0]) ? + (aMessageBoxData->title[0]) ? SetTitle(aMessageBoxData->title) : SetTitle(HAIKU_SDL_DefTitle); - (aMessageBoxData->message && aMessageBoxData->message[0]) ? + (aMessageBoxData->message[0]) ? SetMessageText(aMessageBoxData->message) : SetMessageText(HAIKU_SDL_DefMessage); SetType(ConvertMessageBoxType(static_cast(aMessageBoxData->flags))); diff --git a/src/video/windows/SDL_windowsmessagebox.c b/src/video/windows/SDL_windowsmessagebox.c index 5bf464fa5..8c6ed93ed 100644 --- a/src/video/windows/SDL_windowsmessagebox.c +++ b/src/video/windows/SDL_windowsmessagebox.c @@ -314,7 +314,7 @@ static SDL_bool AddDialogControl(WIN_DialogData *dialog, WORD type, DWORD style, if (!AddDialogData(dialog, &type, sizeof(type))) { return SDL_FALSE; } - if (type == DLGITEMTYPEBUTTON || (type == DLGITEMTYPESTATIC && caption != NULL && caption[0])) { + if (type == DLGITEMTYPEBUTTON || (type == DLGITEMTYPESTATIC && caption[0])) { if (!AddDialogString(dialog, caption)) { return SDL_FALSE; } diff --git a/src/video/x11/SDL_x11messagebox.c b/src/video/x11/SDL_x11messagebox.c index 776a4af52..d7a829b09 100644 --- a/src/video/x11/SDL_x11messagebox.c +++ b/src/video/x11/SDL_x11messagebox.c @@ -245,7 +245,7 @@ X11_MessageBoxInitPositions( SDL_MessageBoxDataX11 *data ) const SDL_MessageBoxData *messageboxdata = data->messageboxdata; /* Go over text and break linefeeds into separate lines. */ - if ( messageboxdata->message && messageboxdata->message[ 0 ] ) { + if ( messageboxdata->message[0] ) { const char *text = messageboxdata->message; const int linecount = CountLinesOfText(text); TextLineData *plinedata = (TextLineData *) SDL_malloc(sizeof (TextLineData) * linecount);