build: fix compiler warnings

- minor moved to <sys/sysmacros.h>
- readdir_r is deprecated
This commit is contained in:
Peifeng Yu 2018-01-03 20:35:37 -05:00
parent 5abd14191c
commit 69588b1094
2 changed files with 7 additions and 12 deletions

View File

@ -181,7 +181,7 @@ void kmscon_load_modules(void)
{
int ret;
DIR *ent;
struct dirent *buf, *de;
struct dirent *de;
char *file;
struct kmscon_module *mod;
@ -203,18 +203,13 @@ void kmscon_load_modules(void)
return;
}
ret = shl_dirent(BUILD_MODULE_DIR, &buf);
if (ret) {
log_error("cannot allocate dirent object");
closedir(ent);
return;
}
while (true) {
ret = readdir_r(ent, buf, &de);
if (ret != 0) {
errno = 0;
de = readdir(ent);
if (!de && errno != 0) {
int errsv = errno;
log_error("cannot read directory %s: %d",
BUILD_MODULE_DIR, ret);
BUILD_MODULE_DIR, errsv);
break;
} else if (!de) {
break;
@ -255,7 +250,6 @@ void kmscon_load_modules(void)
shl_dlist_link(&module_list, &mod->list);
}
free(buf);
closedir(ent);
}

View File

@ -40,6 +40,7 @@
#include <sys/ioctl.h>
#include <sys/signalfd.h>
#include <sys/stat.h>
#include <sys/sysmacros.h>
#include <termios.h>
#include <time.h>
#include <unistd.h>