Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 21 Apr 2018 01:02:35 +0000 (UTC)
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r332850 - head/usr.bin/grep
Message-ID:  <201804210102.w3L12ZUg075848@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kevans
Date: Sat Apr 21 01:02:35 2018
New Revision: 332850
URL: https://svnweb.freebsd.org/changeset/base/332850

Log:
  bsdgrep: Some light cleanup
  
  There's no point checking for a bunch of file modes if we're not a
  practicing believer of DIR_SKIP or DEV_SKIP.
  
  This also reduces some style violations that were particularly ugly looking
  when browsing through.

Modified:
  head/usr.bin/grep/util.c

Modified: head/usr.bin/grep/util.c
==============================================================================
--- head/usr.bin/grep/util.c	Sat Apr 21 00:34:46 2018	(r332849)
+++ head/usr.bin/grep/util.c	Sat Apr 21 01:02:35 2018	(r332850)
@@ -308,14 +308,14 @@ procfile(const char *fn)
 		fn = label != NULL ? label : getstr(1);
 		f = grep_open(NULL);
 	} else {
-		if (!stat(fn, &sb)) {
+		if (stat(fn, &sb) == 0) {
 			/* Check if we need to process the file */
 			s = sb.st_mode & S_IFMT;
-			if (s == S_IFDIR && dirbehave == DIR_SKIP)
+			if (dirbehave == DIR_SKIP && s == S_IFDIR)
 				return (0);
-			if ((s == S_IFIFO || s == S_IFCHR || s == S_IFBLK
-				|| s == S_IFSOCK) && devbehave == DEV_SKIP)
-					return (0);
+			if (devbehave == DEV_SKIP && (s == S_IFIFO ||
+			    s == S_IFCHR || s == S_IFBLK || s == S_IFSOCK))
+				return (0);
 		}
 		f = grep_open(fn);
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201804210102.w3L12ZUg075848>