svn commit: r366356 - stable/12/usr.bin/procstat

Konstantin Belousov kib at FreeBSD.org
Fri Oct 2 10:03:18 UTC 2020


Author: kib
Date: Fri Oct  2 10:03:17 2020
New Revision: 366356
URL: https://svnweb.freebsd.org/changeset/base/366356

Log:
  MFC r366237:
  procstat: Fix regression after 365880.

Modified:
  stable/12/usr.bin/procstat/procstat.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/usr.bin/procstat/procstat.c
==============================================================================
--- stable/12/usr.bin/procstat/procstat.c	Fri Oct  2 07:30:11 2020	(r366355)
+++ stable/12/usr.bin/procstat/procstat.c	Fri Oct  2 10:03:17 2020	(r366356)
@@ -422,9 +422,7 @@ main(int argc, char *argv[])
 	argc -= optind;
 	argv += optind;
 
-	if (cmd == NULL && argv[0] != NULL)
-		cmd = getcmd(argv[0]);
-	if (cmd != NULL) {
+	if (cmd == NULL && argv[0] != NULL && (cmd = getcmd(argv[0])) != NULL) {
 		if ((procstat_opts & PS_SUBCOMMAND_OPTS) != 0)
 			usage(cmd);
 		if (cmd->opt != NULL) {
@@ -440,12 +438,13 @@ main(int argc, char *argv[])
 			argv += 1;
 		}
 	} else {
-		cmd = getcmd("basic");
+		if (cmd == NULL)
+			cmd = getcmd("basic");
+		if (cmd->cmd != procstat_files &&
+		    (procstat_opts & PS_OPT_CAPABILITIES) != 0 &&
+		    (cmd->cmp & PS_MODE_COMPAT) == 0)
+			usage(cmd);
 	}
-	if (cmd->cmd != procstat_files &&
-	    (procstat_opts & PS_OPT_CAPABILITIES) != 0 &&
-	    (cmd->cmp & PS_MODE_COMPAT) == 0)
-		usage(cmd);
 
 	/* Must specify either the -a flag or a list of pids. */
 	if (!(aflag == 1 && argc == 0) && !(aflag == 0 && argc > 0))


More information about the svn-src-stable mailing list