More work on replace deprecated readdir_r()
authorArt Cancro <ajc@citadel.org>
Fri, 29 Dec 2017 23:20:59 +0000 (18:20 -0500)
committerArt Cancro <ajc@citadel.org>
Fri, 29 Dec 2017 23:20:59 +0000 (18:20 -0500)
citadel/modules/bio/serv_bio.c
citadel/modules/image/serv_image.c
citadel/modules/network/serv_netspool.c

index 1c03c480546a6927e4e703f40219ea0d5a205faf..c9d94943f27c63daa50354583199d63148b49a40 100644 (file)
@@ -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);
 }
index a7960b10097ebb0697e8c350baa62d1dbb573856..b8215ca6c5595d0fcfc4543c510dc55251a470e3 100644 (file)
@@ -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);
 }
index 34ad8a6c4e3d998e99a1aeaa9c8fabccf9532d92..a792601b34f29a8539554d5d664902d771f78150 100644 (file)
@@ -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);
 }