mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-01-18 18:56:25 +00:00
Fix compile warning - readdir_r() is deprecated
This commit is contained in:
parent
30b2c1ea3f
commit
a789816916
20
log.c
20
log.c
@ -541,17 +541,15 @@ static void _open_log_file(_log_iterator *it)
|
||||
memset(&oldest, 0, sizeof oldest);
|
||||
unsigned count = 0;
|
||||
while (1) {
|
||||
struct dirent ent;
|
||||
struct dirent *ep;
|
||||
int err = readdir_r(d, &ent, &ep);
|
||||
if (err) {
|
||||
_logs_printf_nl(LOG_LEVEL_ERROR, __HERE__, "Cannot expire log files: r_readdir(%s) - %s [errno=%d]", dir, strerror(err), err);
|
||||
errno = 0;
|
||||
struct dirent *ent = readdir(d);
|
||||
if (ent == NULL) {
|
||||
if (errno)
|
||||
_logs_printf_nl(LOG_LEVEL_ERROR, __HERE__, "Cannot expire log files: readdir(%s) - %s [errno=%d]", dir, strerror(errno), errno);
|
||||
break;
|
||||
}
|
||||
if (!ep)
|
||||
break;
|
||||
const char *e;
|
||||
if ( str_startswith(ent.d_name, "serval-", &e)
|
||||
if ( str_startswith(ent->d_name, "serval-", &e)
|
||||
&& isdigit(e[0]) && isdigit(e[1]) && isdigit(e[2]) && isdigit(e[3]) // YYYY
|
||||
&& isdigit(e[4]) && isdigit(e[5]) // MM
|
||||
&& isdigit(e[6]) && isdigit(e[7]) // DD
|
||||
@ -561,10 +559,10 @@ static void _open_log_file(_log_iterator *it)
|
||||
&& strcmp(&e[14], ".log") == 0
|
||||
) {
|
||||
++count;
|
||||
if ( strcmp(ent.d_name, base) != 0
|
||||
&& (!oldest.d_name[0] || strcmp(ent.d_name, oldest.d_name) < 0)
|
||||
if ( strcmp(ent->d_name, base) != 0
|
||||
&& (!oldest.d_name[0] || strcmp(ent->d_name, oldest.d_name) < 0)
|
||||
)
|
||||
oldest = ent;
|
||||
oldest = *ent;
|
||||
}
|
||||
}
|
||||
closedir(d);
|
||||
|
Loading…
Reference in New Issue
Block a user