summaryrefslogtreecommitdiff
path: root/inittab.c
diff options
context:
space:
mode:
authorJohn Crispin <blogic@openwrt.org>2015-03-28 15:41:58 +0100
committerJohn Crispin <blogic@openwrt.org>2015-03-28 18:35:21 +0100
commit91da63d3d3fd680c805dd1a1b78df5b8731a8173 (patch)
treeec9a568a398ae536ccf7ac89a23942a60ef25c98 /inittab.c
parent74d835463e05e5761f6f5271e487f299f29d3f07 (diff)
downloadprocd-91da63d3d3fd680c805dd1a1b78df5b8731a8173.tar.gz
properly handle return codes
Signed-off-by: John Crispin <blogic@openwrt.org>
Diffstat (limited to 'inittab.c')
-rw-r--r--inittab.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/inittab.c b/inittab.c
index 623103d..eb402f8 100644
--- a/inittab.c
+++ b/inittab.c
@@ -70,9 +70,11 @@ static int dev_open(const char *dev)
int fd = -1;
if (dev) {
- chdir("/dev");
- fd = open( dev, O_RDWR);
- chdir("/");
+ if (chdir("/dev"))
+ ERROR("failed to change dir to /dev\n");
+ fd = open(dev, O_RDWR);
+ if (chdir("/"))
+ ERROR("failed to change dir to /\n");
}
return fd;
@@ -83,9 +85,8 @@ static int dev_exist(const char *dev)
int res;
res = dev_open(dev);
- if (res != -1) {
+ if (res != -1)
close(res);
- }
return (res != -1);
}