aboutsummaryrefslogtreecommitdiff
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 2b35ad8a3..6907e9814 100644
--- a/libbb/device_open.c
+++ b/libbb/device_open.c
@@ -12,15 +12,17 @@
12/* try to open up the specified device */ 12/* try to open up the specified device */
13int device_open(const char *device, int mode) 13int device_open(const char *device, int mode)
14{ 14{
15 int m, f, fd = -1; 15 int m, f, fd;
16 16
17 m = mode | O_NONBLOCK; 17 m = mode | O_NONBLOCK;
18 18
19 /* Retry up to 5 times */ 19 /* Retry up to 5 times */
20 /* TODO: explain why it can't be considered insane */ 20 /* TODO: explain why it can't be considered insane */
21 for (f = 0; f < 5; f++) 21 for (f = 0; f < 5; f++) {
22 if ((fd = open(device, m, 0600)) >= 0) 22 fd = open(device, m, 0600);
23 if (fd >= 0)
23 break; 24 break;
25 }
24 if (fd < 0) 26 if (fd < 0)
25 return fd; 27 return fd;
26 /* Reset original flags. */ 28 /* Reset original flags. */