summaryrefslogtreecommitdiff
path: root/libbb/device_open.c
diff options
context:
space:
mode:
Diffstat (limited to 'libbb/device_open.c')
-rw-r--r--libbb/device_open.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/libbb/device_open.c b/libbb/device_open.c
index 2b35ad8..6907e98 100644
--- a/libbb/device_open.c
+++ b/libbb/device_open.c
@@ -12,15 +12,17 @@
/* try to open up the specified device */
int device_open(const char *device, int mode)
{
- int m, f, fd = -1;
+ int m, f, fd;
m = mode | O_NONBLOCK;
/* Retry up to 5 times */
/* TODO: explain why it can't be considered insane */
- for (f = 0; f < 5; f++)
- if ((fd = open(device, m, 0600)) >= 0)
+ for (f = 0; f < 5; f++) {
+ fd = open(device, m, 0600);
+ if (fd >= 0)
break;
+ }
if (fd < 0)
return fd;
/* Reset original flags. */