static int ff_find_device(void)
{
DIR *dir;
+ struct dirent entry;
struct dirent *dent;
char ev_path[PATH_MAX];
unsigned long features[1+FF_MAX/sizeof(unsigned long)];
if (!dir)
return -errno;
- while ((dent = readdir(dir))) {
+ while (1) {
+ ret = readdir_r(dir, &entry, &dent);
+ if (ret != 0 || dent == NULL)
+ break;
+
if (dent->d_type == DT_DIR ||
!strstr(dent->d_name, "event"))
continue;
/* open ff driver */
ff_fd = open(ff_path, O_RDWR);
if (!ff_fd) {
- _E("Failed to open %s : %s", ff_path, strerror(errno));
+ _E("Failed to open %s : %d", ff_path, errno);
return -errno;
}
}
/* allocate memory */
info = calloc(sizeof(struct ff_info), 1);
if (!info) {
- _E("Failed to allocate memory : %s", strerror(errno));
+ _E("Failed to allocate memory : %d", errno);
return -errno;
}
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
-#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
/* Get File Stream Pointer */
pf = fopen(file_name, "rb");
if (!pf) {
- _E("fopen failed : %s", strerror(errno));
+ _E("fopen failed : %d", errno);
return NULL;
}
error:
fclose(pf);
- _E("failed to convert file to buffer (%s)", strerror(errno));
+ _E("failed to convert file to buffer (%d)", errno);
return NULL;
}
file = fopen(file_path, "wb+");
if (file == NULL) {
- _E("To open file is failed : %s", strerror(errno));
+ _E("To open file is failed : %d", errno);
return -1;
}
if (fwrite(data, 1, size, file) != size) {
- _E("To write file is failed : %s", strerror(errno));
+ _E("To write file is failed : %d", errno);
fclose(file);
return -1;
}
fd = fileno(file);
if (fd < 0) {
- _E("To get file descriptor is failed : %s", strerror(errno));
+ _E("To get file descriptor is failed : %d", errno);
fclose(file);
return -1;
}
if (fsync(fd) < 0) {
- _E("To be synchronized with the disk is failed : %s", strerror(errno));
+ _E("To be synchronized with the disk is failed : %d", errno);
fclose(file);
return -1;
}