summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre-Yves Ritschard <pyr@cvs.openbsd.org>2009-01-29 13:07:10 +0000
committerPierre-Yves Ritschard <pyr@cvs.openbsd.org>2009-01-29 13:07:10 +0000
commit77b88de914062d31ba5f4914a71ffc41a8fd836f (patch)
treeb2005bbb1aad3b926ebcfd43e6edf42058c864c5
parentf2d99bc67c64b127af29db19d8973f978dd85ee2 (diff)
simplify the bpf opening loop a bit.
``shorter is always better'' and ok mbalmer@
-rw-r--r--usr.sbin/wake/wake.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/usr.sbin/wake/wake.c b/usr.sbin/wake/wake.c
index 8ae3db3dab3..bb6b61e37b1 100644
--- a/usr.sbin/wake/wake.c
+++ b/usr.sbin/wake/wake.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wake.c,v 1.4 2009/01/29 10:43:36 michele Exp $ */
+/* $OpenBSD: wake.c,v 1.5 2009/01/29 13:07:09 pyr Exp $ */
/*
* Copyright (C) 2006-2008 Marc Balmer.
@@ -107,21 +107,14 @@ get_bpf(void)
asprintf(&path, BPF_PATH_FORMAT, i);
if (path == NULL)
return -1;
+
fd = open(path, O_RDWR);
- if (fd != -1) {
- free(path);
+ free(path);
+ if (fd != -1)
return fd;
- }
- switch (errno) {
- case EBUSY:
- free(path);
+ if (errno == EBUSY)
continue;
- case ENOENT:
- free(path);
- return -1;
- }
- free(path);
- return -1;
+ break;
}
return -1;
}