From: Art Cancro Date: Fri, 29 Dec 2017 23:20:59 +0000 (-0500) Subject: More work on replace deprecated readdir_r() X-Git-Tag: v939~476 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=8892feee2ba5acef4ff399fc1f019aae2234989a More work on replace deprecated readdir_r() --- diff --git a/citadel/modules/bio/serv_bio.c b/citadel/modules/bio/serv_bio.c index 1c03c4805..c9d94943f 100644 --- a/citadel/modules/bio/serv_bio.c +++ b/citadel/modules/bio/serv_bio.c @@ -146,7 +146,6 @@ void import_old_bio_files(void) { DIR *filedir = NULL; struct dirent *filedir_entry; - struct dirent *d; size_t d_namelen; struct ctdluser usbuf; long usernum = 0; @@ -156,14 +155,8 @@ void import_old_bio_files(void) syslog(LOG_DEBUG, "Importing old style bio files into the message base"); - d = (struct dirent *)malloc(offsetof(struct dirent, d_name) + PATH_MAX + 2); - if (d == NULL) { - return; - } - filedir = opendir (ctdl_bio_dir); if (filedir == NULL) { - free(d); return; } while ( (filedir_entry = readdir(filedir)) , (filedir_entry != NULL)) @@ -217,7 +210,6 @@ void import_old_bio_files(void) } } } - free(d); closedir(filedir); rmdir(ctdl_bio_dir); } diff --git a/citadel/modules/image/serv_image.c b/citadel/modules/image/serv_image.c index a7960b100..b8215ca6c 100644 --- a/citadel/modules/image/serv_image.c +++ b/citadel/modules/image/serv_image.c @@ -277,7 +277,6 @@ void import_old_userpic_files(void) { DIR *filedir = NULL; struct dirent *filedir_entry; - struct dirent *d; size_t d_namelen; struct ctdluser usbuf; long usernum = 0; @@ -287,14 +286,8 @@ void import_old_userpic_files(void) syslog(LOG_DEBUG, "Importing old style userpic files into the message base"); - d = (struct dirent *)malloc(offsetof(struct dirent, d_name) + PATH_MAX + 2); - if (d == NULL) { - return; - } - filedir = opendir (ctdl_usrpic_dir); if (filedir == NULL) { - free(d); return; } while ( (filedir_entry = readdir(filedir)) , (filedir_entry != NULL)) @@ -348,7 +341,6 @@ void import_old_userpic_files(void) } } } - free(d); closedir(filedir); rmdir(ctdl_usrpic_dir); } diff --git a/citadel/modules/network/serv_netspool.c b/citadel/modules/network/serv_netspool.c index 34ad8a6c4..a792601b3 100644 --- a/citadel/modules/network/serv_netspool.c +++ b/citadel/modules/network/serv_netspool.c @@ -826,7 +826,7 @@ void network_do_spoolin(HashList *working_ignetcfg, HashList *the_netmap, int *n return; } - while ( (filedir_entry = readdir(filedir)) , (filedir_entry != NULL)) + while ( (filedir_entry = readdir(dp)) , (filedir_entry != NULL)) { #ifdef _DIRENT_HAVE_D_NAMLEN d_namelen = filedir_entry->d_namlen; @@ -900,7 +900,6 @@ void network_consolidate_spoolout(HashList *working_ignetcfg, HashList *the_netm FDIOBuffer FDIO; int d_namelen; DIR *dp; - struct dirent *d; struct dirent *filedir_entry; const char *pch; char spooloutfilename[PATH_MAX]; @@ -913,12 +912,9 @@ void network_consolidate_spoolout(HashList *working_ignetcfg, HashList *the_netm int d_type = 0; /* Step 1: consolidate files in the outbound queue into one file per neighbor node */ - d = (struct dirent *)malloc(offsetof(struct dirent, d_name) + PATH_MAX + 1); - if (d == NULL) return; dp = opendir(ctdl_netout_dir); if (dp == NULL) { - free(d); return; } @@ -927,7 +923,7 @@ void network_consolidate_spoolout(HashList *working_ignetcfg, HashList *the_netm memset(&FDIO, 0, sizeof(FDIOBuffer)); FDIO.IOB = &IOB; - while ( (filedir_entry = readdir(filedir)) , (filedir_entry != NULL)) + while ( (filedir_entry = readdir(dp)) , (filedir_entry != NULL)) { #ifdef _DIRENT_HAVE_D_NAMLEN d_namelen = filedir_entry->d_namlen; @@ -1046,7 +1042,6 @@ void network_consolidate_spoolout(HashList *working_ignetcfg, HashList *the_netm if (nFailed > 0) { FreeStrBuf(&NextHop); syslog(LOG_INFO, "netspool: skipping Spoolcleanup because of %d files unprocessed.", nFailed); - return; } @@ -1054,11 +1049,10 @@ void network_consolidate_spoolout(HashList *working_ignetcfg, HashList *the_netm dp = opendir(ctdl_netout_dir); if (dp == NULL) { FreeStrBuf(&NextHop); - free(d); return; } - while ( (filedir_entry = readdir(filedir)) , (filedir_entry != NULL)) + while ( (filedir_entry = readdir(dp)) , (filedir_entry != NULL)) { #ifdef _DIRENT_HAVE_D_NAMLEN d_namelen = filedir_entry->d_namlen; @@ -1110,7 +1104,6 @@ void network_consolidate_spoolout(HashList *working_ignetcfg, HashList *the_netm } } FreeStrBuf(&NextHop); - free(d); closedir(dp); }