From 805ca1775e35a9d3d36e5477ca50dcc5f6411e8b Mon Sep 17 00:00:00 2001 From: Xin LI Date: Thu, 19 Jan 2017 08:01:35 +0000 Subject: [PATCH] Use S_ISREG instead of manual & (also it's better to compare the result from & and the pattern instead of just assuming it's one bit value). Pointed out by Tianjie Mao . MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D4827 --- usr.bin/sed/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.bin/sed/main.c b/usr.bin/sed/main.c index 742881b649ba..572e837b799a 100644 --- a/usr.bin/sed/main.c +++ b/usr.bin/sed/main.c @@ -391,7 +391,7 @@ mf_fgets(SPACE *sp, enum e_spflag spflag) if (inplace != NULL) { if (lstat(fname, &sb) != 0) err(1, "%s", fname); - if (!(sb.st_mode & S_IFREG)) + if (!S_ISREG(sb.st_mode)) errx(1, "%s: %s %s", fname, "in-place editing only", "works for regular files");