Project

General

Profile

Actions

Feature #5342

closed

prstat -n option should accept 0

Added by Robert Mustacchi over 8 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
cmd - userland programs
Start date:
2014-11-15
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:
External Bug:

Description

We should be able to use x=0 for prstat -nx,y so we only see the summaries

Actions #1

Updated by Igor Kozhukhov over 8 years ago

could you please clean up gcc warnings by attached patch?
easy fix it by this review

../prstat.c: In function 'nlines':
../prstat.c:1171:2: error: suggest parentheses around assignment used as truth value [-Werror=parentheses]
  if (envp = getenv("LINES")) {
  ^
../prstat.c: In function 'fill_table':
../prstat.c:1333:2: error: suggest parentheses around assignment used as truth value [-Werror=parentheses]
  while (p = strtok(NULL, ", "))
  ^
../prstat.c: In function 'fill_prj_table':
../prstat.c:1350:2: error: suggest parentheses around assignment used as truth value [-Werror=parentheses]
  while (p = strtok(NULL, ", ")) {
  ^
../prstat.c: In function 'fill_set_table':
../prstat.c:1369:2: error: suggest parentheses around assignment used as truth value [-Werror=parentheses]
  while (p = strtok(NULL, ", ")) {
  ^
../prstat.c: In function 'main':
../prstat.c:1463:4: error: suggest parentheses around assignment used as truth value [-Werror=parentheses]
    if (p = strtok(NULL, ","))
    ^
../prstat.c:1479:4: error: suggest parentheses around assignment used as truth value [-Werror=parentheses]
    while (p = strtok(NULL, ", "))
    ^
../prstat.c:1486:4: error: suggest parentheses around assignment used as truth value [-Werror=parentheses]
    while (p = strtok(NULL, ", "))
    ^
../prstat.c:1515:4: error: suggest parentheses around assignment used as truth value [-Werror=parentheses]
    while (p = strtok(NULL, ", "))
    ^
cc1: all warnings being treated as errors
*** Error code 1

diff --git a/usr/src/cmd/prstat/Makefile.com b/usr/src/cmd/prstat/Makefile.com
index e317483..84aac0d 100644
--- a/usr/src/cmd/prstat/Makefile.com
+++ b/usr/src/cmd/prstat/Makefile.com
@@ -32,7 +32,6 @@ SRCS = $(OBJS:%.o=../%.c)
 include ../../Makefile.cmd

 CFLAGS += $(CCVERBOSE)
-CERRWARN += -_gcc=-Wno-parentheses
 LDLIBS += -lcurses -lproject
 LINTFLAGS += -u
 LINTFLAGS64 += -u
diff --git a/usr/src/cmd/prstat/prstat.c b/usr/src/cmd/prstat/prstat.c
index a495108..fa56a3c 100644
--- a/usr/src/cmd/prstat/prstat.c
+++ b/usr/src/cmd/prstat/prstat.c
@@ -1168,7 +1168,7 @@ nlines()
                if (ws.ws_row > 0)
                        return (ws.ws_row);
        }
-       if (envp = getenv("LINES")) {
+       if ((envp = getenv("LINES")) != NULL) {
                if ((n = Atoi(envp)) > 0) {
                        opts.o_outpmode &= ~OPT_USEHOME;
                        return (n);
@@ -1330,7 +1330,7 @@ fill_table(table_t *table, char *arg, char option)
                Die(gettext("invalid argument for -%c\\n"), option);

        add_element(table, (long)Atoi(p));
-       while (p = strtok(NULL, ", "))
+       while ((p = strtok(NULL, ", ")) != NULL)
                add_element(table, (long)Atoi(p));
 }

@@ -1347,7 +1347,7 @@ fill_prj_table(char *arg)
                projid = Atoi(p);
        add_element(&prj_tbl, (long)projid);

-       while (p = strtok(NULL, ", ")) {
+       while ((p = strtok(NULL, ", ")) != NULL) {
                if ((projid = getprojidbyname(p)) == -1)
                        projid = Atoi(p);
                add_element(&prj_tbl, (long)projid);
@@ -1366,7 +1366,7 @@ fill_set_table(char *arg)
        if ((id = Atoi(p)) == 0)
                id = PS_NONE;
        add_element(&set_tbl, id);
-       while (p = strtok(NULL, ", ")) {
+       while ((p = strtok(NULL, ", ")) != NULL) {
                if ((id = Atoi(p)) == 0)
                        id = PS_NONE;
                if (!has_element(&set_tbl, id))
@@ -1460,7 +1460,7 @@ main(int argc, char **argv)
                        if ((p = strtok(optarg, ",")) == NULL)
                                Die(gettext("invalid argument for -n\\n"));
                        opts.o_ntop = Atoi(p);
-                       if (p = strtok(NULL, ","))
+                       if ((p = strtok(NULL, ",")) != NULL)
                                opts.o_nbottom = Atoi(p);
                        opts.o_outpmode &= ~OPT_FULLSCREEN;
                        break;
@@ -1476,14 +1476,14 @@ main(int argc, char **argv)
                        if ((p = strtok(optarg, ", ")) == NULL)
                                Die(gettext("invalid argument for -u\\n"));
                        add_uid(&euid_tbl, p);
-                       while (p = strtok(NULL, ", "))
+                       while ((p = strtok(NULL, ", ")) != NULL)
                                add_uid(&euid_tbl, p);
                        break;
                case 'U':
                        if ((p = strtok(optarg, ", ")) == NULL)
                                Die(gettext("invalid argument for -U\\n"));
                        add_uid(&ruid_tbl, p);
-                       while (p = strtok(NULL, ", "))
+                       while ((p = strtok(NULL, ", ")) != NULL)
                                add_uid(&ruid_tbl, p);
                        break;
                case 'p':
@@ -1512,7 +1512,7 @@ main(int argc, char **argv)
                        if ((p = strtok(optarg, ", ")) == NULL)
                                Die(gettext("invalid argument for -z\\n"));
                        add_zone(&zone_tbl, p);
-                       while (p = strtok(NULL, ", "))
+                       while ((p = strtok(NULL, ", ")) != NULL)
                                add_zone(&zone_tbl, p);
                        break;
                case 'Z':
Actions #2

Updated by Robert Mustacchi over 8 years ago

That kind of clean up should just be a separate issue. If we had introduced something to gag it, it'd make sense, but I see no reason to conflate Jerry's work with your work. You should just create a separate issue and take the credit for what you've done.

Actions #3

Updated by Electric Monk over 8 years ago

  • Status changed from New to Closed

git commit 156d6b3a5d0ba06e75f7973c6ba994107ae8df0e

commit  156d6b3a5d0ba06e75f7973c6ba994107ae8df0e
Author: Jerry Jelinek <jerry.jelinek@joyent.com>
Date:   2014-12-05T21:38:51.000Z

    5342 prstat -n option should accept 0
    Reviewed by: Robert Mustacchi <rm@joyent.com>
    Reviewed by: Gordon Ross <gwr@nexenta.com>
    Reviewed by: Andy Stormont <astormont@racktopsystems.com>
    Approved by: Dan McDonald <danmcd@omniti.com>

Actions

Also available in: Atom PDF