add an internal error code definition
[exim.git] / src / src / spool_mbox.c
index caf1712cf7dde5619870e963826ed769e7b6dff5..cf7909fbe2b628afe0a3be75c9ccd5bb67d60bea 100644 (file)
@@ -4,7 +4,7 @@
 
 /* Copyright (c) Tom Kistner <tom@duncanthrax.net> 2003 - 2015
  * License: GPL
- * Copyright (c) The Exim Maintainers 2016 - 2018
+ * Copyright (c) The Exim Maintainers 2016 - 2020
  */
 
 /* Code for setting up a MBOX style spool file inside a /scan/<msgid>
@@ -53,8 +53,8 @@ if (!spool_mbox_ok)
   temp_string = string_sprintf("scan/%s", message_id);
   if (!directory_make(spool_directory, temp_string, 0750, FALSE))
     {
-    log_write(0, LOG_MAIN|LOG_PANIC, "%s", string_open_failed(errno,
-      "scan directory %s/scan/%s", spool_directory, temp_string));
+    log_write(0, LOG_MAIN|LOG_PANIC, "%s",
+      string_open_failed("scan directory %s/scan/%s", spool_directory, temp_string));
     goto OUT;
     }
 
@@ -62,8 +62,8 @@ if (!spool_mbox_ok)
 
   if (!(mbox_file = modefopen(mbox_path, "wb", SPOOL_MODE)))
     {
-    log_write(0, LOG_MAIN|LOG_PANIC, "%s", string_open_failed(errno,
-      "scan file %s", mbox_path));
+    log_write(0, LOG_MAIN|LOG_PANIC, "%s",
+      string_open_failed("scan file %s", mbox_path));
     goto OUT;
     }
 
@@ -117,7 +117,7 @@ if (!spool_mbox_ok)
     message_subdir[1] = '\0';
     for (int i = 0; i < 2; i++)
       {
-      message_subdir[0] = split_spool_directory == (i == 0) ? message_id[5] : 0;
+      set_subdir_str(message_subdir, message_id, i);
       temp_string = spool_fname(US"input", message_subdir, message_id, US"-D");
       if ((l_data_file = Ufopen(temp_string, "rb"))) break;
       }
@@ -185,8 +185,8 @@ if (!spool_mbox_ok)
 if (  !(yield = Ufopen(mbox_path,"rb"))
    || fstat(fileno(yield), &statbuf) != 0
    )
-  log_write(0, LOG_MAIN|LOG_PANIC, "%s", string_open_failed(errno,
-    "scan file %s", mbox_path));
+  log_write(0, LOG_MAIN|LOG_PANIC, "%s",
+    string_open_failed( "scan file %s", mbox_path));
 else
   *mbox_file_size = statbuf.st_size;
 
@@ -211,12 +211,11 @@ malware_ok = 0;
 if (spool_mbox_ok && !f.no_mbox_unspool)
   {
   uschar *file_path;
-  struct dirent *entry;
   DIR *tempdir;
   rmark reset_point = store_mark();
   uschar * mbox_path = string_sprintf("%s/scan/%s", spool_directory, spooled_message_id);
 
-  if (!(tempdir = opendir(CS mbox_path)))
+  if (!(tempdir = exim_opendir(mbox_path)))
     {
     debug_printf("Unable to opendir(%s): %s\n", mbox_path, strerror(errno));
     /* Just in case we still can: */
@@ -224,15 +223,14 @@ if (spool_mbox_ok && !f.no_mbox_unspool)
     return;
     }
   /* loop thru dir & delete entries */
-  while((entry = readdir(tempdir)))
+  for (struct dirent *entry; entry = readdir(tempdir); )
     {
     uschar *name = US entry->d_name;
-    int dummy;
     if (Ustrcmp(name, US".") == 0 || Ustrcmp(name, US"..") == 0) continue;
 
     file_path = string_sprintf("%s/%s", mbox_path, name);
     debug_printf("unspool_mbox(): unlinking '%s'\n", file_path);
-    dummy = unlink(CS file_path); dummy = dummy;       /* compiler quietening */
+    (void) unlink(CS file_path);
     }
 
   closedir(tempdir);