top: fix selected miscellaneous compiler warnings

These per instance warnings have been eliminated:
warning: range expressions in switch statements are non-standard
warning: padding struct to align 'winflags'
warning: dereferencing type-punned pointer will break strict-aliasing rules

   These per instance warnings have not been addressed
   since they simply trade one warning for another:
      From:
warning: ISO C does not permit named variadic macros
warning: ISO C does not support the '%Lu' gnu_scanf format
      To:
warning: anonymous variadic macros were introduced in C99
warning: ISO C90 does not support the 'll' gnu_scanf length modifier

   Lastly, since all C compilers have supported use of
   C++ style comments for the past 20 years, the top
   program will never trade them for the often more
   cumbersome C style comments simply to avoid this
   once per source file warning:
warning: C++ style comments are not allowed in ISO C90

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2012-03-05 11:22:33 -06:00 committed by Craig Small
parent ddd15211e0
commit 87bb21b557
2 changed files with 8 additions and 6 deletions

View File

@ -761,7 +761,8 @@ static void show_special (int interact, const char *glob) {
case 0: // no end delim, captab makes normal
*(sub_end + 1) = '\0'; // extend str end, then fall through
*(sub_end + 2) = '\0'; // ( +1 optimization for usual path )
case 1 ... 8:
case 1: case 2: case 3: case 4:
case 5: case 6: case 7: case 8:
*sub_end = '\0';
snprintf(tmp, sizeof(tmp), "%s%.*s%s", Curwin->captab[ch], room, sub_beg, Caps_off);
rp = scat(rp, tmp);
@ -2299,7 +2300,7 @@ static void configs_read (void) {
# error Hey, fix the above fscanf 'PFLAGSSIZ' dependency !
#endif
if (3 != fscanf(fp, "\twinflags=%d, sortindx=%d, maxtasks=%d\n"
, &w->rc.winflags, (int*)&w->rc.sortindx, &w->rc.maxtasks))
, &w->rc.winflags, &w->rc.sortindx, &w->rc.maxtasks))
goto default_or_error;
if (4 != fscanf(fp, "\tsummclr=%d, msgsclr=%d, headclr=%d, taskclr=%d\n"
, &w->rc.summclr, &w->rc.msgsclr
@ -2569,7 +2570,7 @@ static WIN_t *win_select (char ch) {
case 'w': // (however those letters work via
w = w->prev; // the pmt too but gee, end-loser
break; // should just press the darn key)
case '1' ... '4':
case '1': case '2' : case '3': case '4':
w = &Winstk[ch - '1'];
break;
default: // keep gcc happy
@ -2664,7 +2665,8 @@ static void wins_colors (void) {
clr = *pclr;
tgt = ch;
break;
case '0' ... '7':
case '0': case '1': case '2': case '3':
case '4': case '5': case '6': case '7':
clr = ch - '0';
*pclr = clr;
break;

View File

@ -291,8 +291,8 @@ enum warn_enum {
/* This type helps support both a window AND the rcfile */
typedef struct RCW_t { // the 'window' portion of an rcfile
FLG_t sortindx; // sort field, represented as a procflag
int winflags, // 'view', 'show' and 'sort' mode flags
int sortindx, // sort field, represented as a procflag
winflags, // 'view', 'show' and 'sort' mode flags
maxtasks, // user requested maximum, 0 equals all
summclr, // color num used in summ info
msgsclr, // " in msgs/pmts