summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2014-05-25 11:54:55 +0200
committerDavid Herrmann <dh.herrmann@gmail.com>2014-05-25 11:56:50 +0200
commit074792020c9cec199959d4f5c39f3ef21318c031 (patch)
treef49c3876c51d855dd35af2e8bc7f9347aecd6457
parent41e76d11dff6dd9bc08bf829751f9634f32cdd38 (diff)
downloadkmscon-074792020c9cec199959d4f5c39f3ef21318c031.tar.gz
kmscon-074792020c9cec199959d4f5c39f3ef21318c031.tar.bz2
kmscon-074792020c9cec199959d4f5c39f3ef21318c031.zip
Partly revert "shl: handle pathconf() errors"upstream
This partly reverts commit 41e76d11dff6dd9bc08bf829751f9634f32cdd38. I removed the "superfluous" errno-handling, which in fact is needed. Turns out pathconf() might leave errno unchanged. Reported-by: Lubomir Rintel <lkundrak@v3.sk> Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
-rw-r--r--src/kmscon_module.c2
-rw-r--r--src/shl_misc.h10
2 files changed, 9 insertions, 3 deletions
diff --git a/src/kmscon_module.c b/src/kmscon_module.c
index f480914..2bf0576 100644
--- a/src/kmscon_module.c
+++ b/src/kmscon_module.c
@@ -181,7 +181,7 @@ void kmscon_load_modules(void)
{
int ret;
DIR *ent;
- struct dirent *buf = NULL, *de;
+ struct dirent *buf, *de;
char *file;
struct kmscon_module *mod;
diff --git a/src/shl_misc.h b/src/shl_misc.h
index f4a6d90..fc37d9d 100644
--- a/src/shl_misc.h
+++ b/src/shl_misc.h
@@ -54,9 +54,15 @@ static inline int shl_dirent(const char *path, struct dirent **ent)
struct dirent *tmp;
long name_max;
+ /* errno may be left unchanged, see pathconf(3p) */
+ errno = 0;
name_max = pathconf(path, _PC_NAME_MAX);
- if (name_max < 0)
- return -errno;
+ if (name_max < 0) {
+ if (errno)
+ return -errno;
+ else
+ return -EINVAL;
+ }
len = offsetof(struct dirent, d_name) + name_max + 1;
tmp = malloc(len);