From 61656abc7ff84215165af1bd464bc053b3b66158 Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Fri, 28 Jun 2019 13:35:06 +0000 Subject: When system calls indicate an error they return -1, not some arbitrary value < 0. errno is only updated in this case. Change all (most?) callers of syscalls to follow this better, and let's see if this strictness helps us in the future. --- usr.bin/wc/wc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'usr.bin/wc') diff --git a/usr.bin/wc/wc.c b/usr.bin/wc/wc.c index db3a89ea0af..b1e24552cd9 100644 --- a/usr.bin/wc/wc.c +++ b/usr.bin/wc/wc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wc.c,v 1.25 2018/09/30 12:44:22 schwarze Exp $ */ +/* $OpenBSD: wc.c,v 1.26 2019/06/28 13:35:05 deraadt Exp $ */ /* * Copyright (c) 1980, 1987, 1991, 1993 @@ -132,7 +132,7 @@ cnt(char *file) linect = wordct = charct = 0; stream = NULL; if (file) { - if ((fd = open(file, O_RDONLY, 0)) < 0) { + if ((fd = open(file, O_RDONLY, 0)) == -1) { warn("%s", file); rval = 1; return; -- cgit v1.2.3