From a08f5630d83328a38602b47f74f2728489656377 Mon Sep 17 00:00:00 2001 From: Olaf Meeuwissen Date: Sat, 8 Jul 2017 17:58:49 +0900 Subject: [PATCH] sanei_scsi: Fix [-Wdeprecated-declarations] compiler warning The readdir_r() using loop in sanei_scsi_find_devices() has been modified to use readdir(). With the exception of sane_cancel(), the SANE API is not re-entrant. The sanei_scsi_find_devices() function is referenced neither directly nor indirectly from any of the sane_cancel() implementations so there is no inherent need to use readdir_r(). --- sanei/sanei_scsi.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/sanei/sanei_scsi.c b/sanei/sanei_scsi.c index 3b407046d..ca3dbb0ff 100644 --- a/sanei/sanei_scsi.c +++ b/sanei/sanei_scsi.c @@ -2945,8 +2945,7 @@ sanei_scsi_find_devices (const char *findvendor, const char *findmodel, char *me = "sanei_scsi_find_devices"; char path[PATH_MAX]; char dev_name[128]; - struct dirent buf; - struct dirent *de; + struct dirent *buf; DIR *scsidevs; FILE *fp; char *ptr; @@ -2987,8 +2986,9 @@ sanei_scsi_find_devices (const char *findvendor, const char *findmodel, number = -1; for (;;) { - ret = readdir_r(scsidevs, &buf, &de); - if (ret != 0) + errno = 0; + buf = readdir (scsidevs); + if (errno != 0) { DBG (1, "%s: could not read directory %s: %s\n", me, SYSFS_SCSI_DEVICES, strerror(errno)); @@ -2996,14 +2996,14 @@ sanei_scsi_find_devices (const char *findvendor, const char *findmodel, break; } - if (de == NULL) + if (buf == NULL) break; - if (buf.d_name[0] == '.') + if (buf->d_name[0] == '.') continue; /* Extract bus, channel, id, lun from directory name b:c:i:l */ - ptr = buf.d_name; + ptr = buf->d_name; for (i = 0; i < 4; i++) { errno = 0; @@ -3028,7 +3028,7 @@ sanei_scsi_find_devices (const char *findvendor, const char *findmodel, if (*end && (*end != ':')) { - DBG (1, "%s: parse error on string %s (%d)\n", me, buf.d_name, i); + DBG (1, "%s: parse error on string %s (%d)\n", me, buf->d_name, i); i = 12; /* Skip */ break; @@ -3036,7 +3036,7 @@ sanei_scsi_find_devices (const char *findvendor, const char *findmodel, if (val > INT_MAX) { - DBG (1, "%s: integer value too large (%s)\n", me, buf.d_name); + DBG (1, "%s: integer value too large (%s)\n", me, buf->d_name); i = 12; /* Skip */ break; @@ -3059,11 +3059,11 @@ sanei_scsi_find_devices (const char *findvendor, const char *findmodel, for (i = 0; i < 3; i++) { ret = snprintf (path, PATH_MAX, "%s/%s/%s", - SYSFS_SCSI_DEVICES, buf.d_name, vmtfiles[i]); + SYSFS_SCSI_DEVICES, buf->d_name, vmtfiles[i]); if ((ret < 0) || (ret >= PATH_MAX)) { DBG (1, "%s: skipping %s/%s, PATH_MAX exceeded on %s\n", - me, SYSFS_SCSI_DEVICES, buf.d_name, vmtfiles[i]); + me, SYSFS_SCSI_DEVICES, buf->d_name, vmtfiles[i]); i = 12; /* Skip */ break;