summaryrefslogtreecommitdiff
path: root/lib/libcfg
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-11-23 14:13:52 +0100
committerDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-11-23 23:00:58 +0100
commitd9a5736bdfa9db29e94c5431bb8a9bc92a24585c (patch)
tree59095ed17fac70631b1135101f3e98c583363b2d /lib/libcfg
parentc14c3c0173d7bebeb3ccac687e49909164845d57 (diff)
Remove some no longer needed cruft
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
Diffstat (limited to 'lib/libcfg')
-rw-r--r--lib/libcfg/rdline.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/libcfg/rdline.c b/lib/libcfg/rdline.c
index ab7b101..ee9ee8b 100644
--- a/lib/libcfg/rdline.c
+++ b/lib/libcfg/rdline.c
@@ -5,6 +5,7 @@
#include <errno.h>
#include <ctype.h>
#include <stdio.h>
+#include <fcntl.h>
#include "libcfg.h"
#include "util.h"
@@ -12,18 +13,26 @@
int rdline_init(rdline_t *t, int dirfd, const char *filename,
int argc, const char *const *argv)
{
+ int fd = openat(dirfd, filename, O_RDONLY);
+
+ if (fd == -1)
+ goto fail_open;
+
memset(t, 0, sizeof(*t));
- t->fp = fopenat(dirfd, filename, "r");
+ t->fp = fdopen(fd, "r");
if (t->fp == NULL) {
- perror(filename);
- return -1;
+ close(fd);
+ goto fail_open;
}
t->filename = filename;
t->argc = argc;
t->argv = argv;
return 0;
+fail_open:
+ perror(filename);
+ return -1;
}
void rdline_cleanup(rdline_t *t)