[procps] [PATCH] top.c & top.h: remove warnings
- From: Sami Kerola <kerolasa@xxxxxx>
- To: procps@xxxxxxxxxxxxx
- Date: Wed, 25 May 2011 21:29:42 +0200
The patch will make following (clang) warnings to go away.
warning: Use of comma pasting extension is non-portable [-pedantic]
warning: use of GNU case range extension [-Wgnu]
Signed-off-by: Sami Kerola <kerolasa@xxxxxx>
---
top.c | 25 +++++++++++++++++++++----
top.h | 8 ++++----
2 files changed, 25 insertions(+), 8 deletions(-)
diff --git a/top.c b/top.c
index 06841cb..d237cc0 100644
--- a/top.c
+++ b/top.c
@@ -731,7 +731,14 @@ static void show_special (int interact, const char *glob) {
switch (*sub_end) {
case 0: // no end delim, captab makes normal
*(sub_end + 1) = '\0'; // extend str end, then fall through
- case 1 ... 8:
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ case 6:
+ case 7:
+ case 8:
cap = Curwin->captab[(int)*sub_end];
*sub_end = '\0';
snprintf(tmp, sizeof(tmp), "%s%.*s%s", cap, room, sub_beg,
Caps_off);
@@ -2326,7 +2333,10 @@ 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
@@ -2422,7 +2432,14 @@ 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;
@@ -3135,7 +3152,7 @@ static proc_t **summary_show (void) {
/*
* Display information for a single task row. */
static void task_show (const WIN_t *q, const proc_t *p) {
- #define makeCOL(va...) snprintf(cbuf, sizeof(cbuf), f, ## va)
+ #define makeCOL(...) snprintf(cbuf, sizeof(cbuf), f, __VA_ARGS__)
#define makeVAR(v) { f = VARCOL_fmts; makeCOL(q->varcolsz, q->varcolsz, v); }
#define pages2K(n) (unsigned long)( (n) << Pg2K_shft )
char rbuf[ROWMINSIZ], *rp;
diff --git a/top.h b/top.h
index 804eec4..02ce8e6 100644
--- a/top.h
+++ b/top.h
@@ -391,9 +391,9 @@ typedef struct WIN_t {
. for temporary, possibly interactive, 'replacement' output
. may contain ANY valid terminfo escape sequences
. need NOT represent an entire screen row */
-#define PUTT(fmt,arg...) do { \
+#define PUTT(fmt,...) do { \
char _str[ROWMAXSIZ]; \
- snprintf(_str, sizeof(_str), fmt, ## arg); \
+ snprintf(_str, sizeof(_str), fmt, __VA_ARGS__); \
putp(_str); \
} while (0)
@@ -402,9 +402,9 @@ typedef struct WIN_t {
. may NOT contain cursor motion terminfo escapes
. assumed to represent a complete screen ROW
. subject to optimization, thus MAY be discarded */
-#define PUFF(fmt,arg...) do { \
+#define PUFF(fmt,...) do { \
char _str[ROWMAXSIZ]; \
- snprintf(_str, sizeof(_str), fmt, ## arg); \
+ snprintf(_str, sizeof(_str), fmt, __VA_ARGS__); \
if (Batch) putp(_str); \
else { \
char *_ptr = &Pseudo_screen[Pseudo_row * ROWMAXSIZ]; \
--
1.7.5.2
Other related posts:
- » [procps] [PATCH] top.c & top.h: remove warnings - Sami Kerola