From f3cf3e593358c2ed25b735c5407c40292049a990 Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Sat, 21 Apr 2018 01:02:35 +0000 Subject: [PATCH] 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. --- usr.bin/grep/util.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/usr.bin/grep/util.c b/usr.bin/grep/util.c index 965a4138ebb5..7af2155439dc 100644 --- a/usr.bin/grep/util.c +++ b/usr.bin/grep/util.c @@ -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 (devbehave == DEV_SKIP && (s == S_IFIFO || + s == S_IFCHR || s == S_IFBLK || s == S_IFSOCK)) return (0); - if ((s == S_IFIFO || s == S_IFCHR || s == S_IFBLK - || s == S_IFSOCK) && devbehave == DEV_SKIP) - return (0); } f = grep_open(fn); }