From dda11f0e3811b0ddc2f3b87c83cfc47418aac385 Mon Sep 17 00:00:00 2001 From: Jon Trulson Date: Sat, 11 Dec 2021 13:10:24 -0700 Subject: [PATCH] Fix a bunch of -Wempty-body warnings reported by clang Many of these were real bugs, like: if (cond); do_something etc... Others were just cosmetic - like placing the ';' on a separate line to make the intention clear. --- cde/lib/DtPrint/PsubUtil.c | 3 ++- cde/lib/DtSvc/DtUtil1/GetMwmW.c | 2 +- cde/programs/dtappbuilder/src/ab/attch_ed_stubs.c | 2 +- cde/programs/dtappbuilder/src/ab/prop.c | 6 +++--- cde/programs/dtcalc/functions.c | 5 +++-- cde/programs/dtdocbook/instant/tables.c | 3 ++- cde/programs/dtlogin/util.c | 5 +++-- cde/programs/dtmail/MotifApp/DialogManager.C | 11 ++++++++--- cde/programs/dtmail/libDtMail/Common/DtMailRc.C | 4 ++-- cde/programs/dtmail/libDtMail/Common/DtMailServer.C | 3 ++- cde/programs/dtpad/printSetup.c | 2 +- 11 files changed, 28 insertions(+), 18 deletions(-) diff --git a/cde/lib/DtPrint/PsubUtil.c b/cde/lib/DtPrint/PsubUtil.c index 3359a37b6..aefc3e034 100644 --- a/cde/lib/DtPrint/PsubUtil.c +++ b/cde/lib/DtPrint/PsubUtil.c @@ -573,7 +573,8 @@ _DtPrintGetDefaultXPrinterName( else if((default_printer = getenv("XPRINTER")) != (String)NULL); else if((default_printer = getenv("PDPRINTER")) != (String)NULL); else if((default_printer = getenv("LPDEST")) != (String)NULL); - else if((default_printer = getenv("PRINTER")) != (String)NULL); + else if((default_printer = getenv("PRINTER")) != (String)NULL) + ; /* * return a copy of the printer name */ diff --git a/cde/lib/DtSvc/DtUtil1/GetMwmW.c b/cde/lib/DtSvc/DtUtil1/GetMwmW.c index 5461cefbf..e5f920076 100644 --- a/cde/lib/DtSvc/DtUtil1/GetMwmW.c +++ b/cde/lib/DtSvc/DtUtil1/GetMwmW.c @@ -149,7 +149,7 @@ _GetMwmWindow( } } - if (rcode == Success); + if (rcode == Success) { *pMwmWindow = pWmInfo->wmWindow; } diff --git a/cde/programs/dtappbuilder/src/ab/attch_ed_stubs.c b/cde/programs/dtappbuilder/src/ab/attch_ed_stubs.c index 5377bc44d..700e3d493 100644 --- a/cde/programs/dtappbuilder/src/ab/attch_ed_stubs.c +++ b/cde/programs/dtappbuilder/src/ab/attch_ed_stubs.c @@ -3670,7 +3670,7 @@ attch_ed_verify_props(void) * Get parent of current object */ parent = obj_get_parent(ats->cur_object); - if (parent); + if (parent) parent = obj_get_root(parent); /* diff --git a/cde/programs/dtappbuilder/src/ab/prop.c b/cde/programs/dtappbuilder/src/ab/prop.c index 52fff33e0..b2f19f023 100644 --- a/cde/programs/dtappbuilder/src/ab/prop.c +++ b/cde/programs/dtappbuilder/src/ab/prop.c @@ -2634,11 +2634,11 @@ propP_popup_message( /* * Free help data strings */ - if (help_data.help_text); + if (help_data.help_text) XtFree(help_data.help_text); - if (help_data.help_volume); + if (help_data.help_volume) XtFree(help_data.help_volume); - if (help_data.help_locationID); + if (help_data.help_locationID) XtFree(help_data.help_locationID); } else diff --git a/cde/programs/dtcalc/functions.c b/cde/programs/dtcalc/functions.c index 8658c83fe..1f985dc23 100644 --- a/cde/programs/dtcalc/functions.c +++ b/cde/programs/dtcalc/functions.c @@ -539,8 +539,9 @@ do_calc(void) /* Perform arithmetic calculation and display result. */ mpcdm(&dres, v->MPresult) ; } - else if (IS_KEY(v->cur_op, KEY_EQ)) /* do nothing. */ ; /* Equals */ - + else if (IS_KEY(v->cur_op, KEY_EQ)) /* Equals */ + ; /* do nothing. */ + show_display(v->MPresult) ; if (!(IS_KEY(v->current, KEY_EQ) && IS_KEY(v->old_cal_value, KEY_EQ))) diff --git a/cde/programs/dtdocbook/instant/tables.c b/cde/programs/dtdocbook/instant/tables.c index 9e67e0366..533a99c88 100644 --- a/cde/programs/dtdocbook/instant/tables.c +++ b/cde/programs/dtdocbook/instant/tables.c @@ -768,7 +768,8 @@ TblTableRowEnd( if ((at = FindAttValByName(e, "ROWSEP"))) { if (at[0] == '1') fprintf(fp, "_\n"); } - else if (rowsep) /* fprintf(fp, "_\n") */ ; + else if (rowsep) /* fprintf(fp, "_\n") */ + ; } /* diff --git a/cde/programs/dtlogin/util.c b/cde/programs/dtlogin/util.c index 8e0f51ee2..a46b7ca0c 100644 --- a/cde/programs/dtlogin/util.c +++ b/cde/programs/dtlogin/util.c @@ -705,9 +705,10 @@ ScanNLSDir(char *dirname) continue; if (locale[0] != '.' && - LANGLISTSIZE > (int) (strlen(languageList)+strlen(locale)+2)); + LANGLISTSIZE > (int) (strlen(languageList)+strlen(locale)+2)) { - (void) sprintf(locale_path, "%s/%s", dirname, locale); + (void) snprintf(locale_path, MAXPATHLEN, "%s/%s", + dirname, locale); retval = stat(locale_path, &locale_stat); if (0 == retval && S_ISDIR(locale_stat.st_mode)) diff --git a/cde/programs/dtmail/MotifApp/DialogManager.C b/cde/programs/dtmail/MotifApp/DialogManager.C index 8051a7a44..91ae65c5f 100644 --- a/cde/programs/dtmail/MotifApp/DialogManager.C +++ b/cde/programs/dtmail/MotifApp/DialogManager.C @@ -417,9 +417,14 @@ DialogManager::forceUpdate( Widget w ) if ( !w ) return; XtAppContext cxt=XtWidgetToApplicationContext( w ); - for (diashell=w;!XtIsShell(diashell);diashell=XtParent(diashell)); - for ( topshell=diashell;XtIsTopLevelShell( topshell ); - topshell = XtParent( topshell ) ); + for (diashell=w; + !XtIsShell(diashell); + diashell=XtParent(diashell)) + ; + for ( topshell=diashell; + XtIsTopLevelShell( topshell ); + topshell = XtParent( topshell ) ) + ; // if (XtIsRealized(diashell) && XtIsRealized(topshell)){ dpy=XtDisplay(diashell); diff --git a/cde/programs/dtmail/libDtMail/Common/DtMailRc.C b/cde/programs/dtmail/libDtMail/Common/DtMailRc.C index a2794c530..b4732147b 100644 --- a/cde/programs/dtmail/libDtMail/Common/DtMailRc.C +++ b/cde/programs/dtmail/libDtMail/Common/DtMailRc.C @@ -2050,8 +2050,8 @@ DtMail::MailRc::expand(char *name) close(pivec[1]); l = read(pivec[0], xname, LINESIZE); close(pivec[0]); - while (wait(&s) != pid); - ; + while (wait(&s) != pid) + ; s &= 0377; if (s != 0 && s != SIGPIPE) { fprintf(stderr, "Echo failed\n"); diff --git a/cde/programs/dtmail/libDtMail/Common/DtMailServer.C b/cde/programs/dtmail/libDtMail/Common/DtMailServer.C index 112b15872..861d06afd 100644 --- a/cde/programs/dtmail/libDtMail/Common/DtMailServer.C +++ b/cde/programs/dtmail/libDtMail/Common/DtMailServer.C @@ -789,8 +789,9 @@ DtMailServer::retrieve_messages(DtMailEnv &error) if (ok != DTME_MailServerAccess_SocketIOError) if (ok == DTME_NoError) ok = ptrans_quit(); - else + else { (void) ptrans_quit(); + } vtalarm_setitimer(0); SockClose(_sockfp); _sockfp = NULL; diff --git a/cde/programs/dtpad/printSetup.c b/cde/programs/dtpad/printSetup.c index 8191bbde6..4ae105e7e 100644 --- a/cde/programs/dtpad/printSetup.c +++ b/cde/programs/dtpad/printSetup.c @@ -280,7 +280,7 @@ PrintSetupDestroy(PrintSetup *pSetup) if (pSetup->docName) free(pSetup->docName); - if (pSetup->dtprintSetup); + if (pSetup->dtprintSetup) _psReleasePrintSetupDialog(pSetup); XtFree((char*) pSetup); }