]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
win32: code cleanup
authorAlain Spineux <alain@baculasystems.com>
Fri, 17 Feb 2023 18:10:03 +0000 (19:10 +0100)
committerEric Bollengier <eric@baculasystems.com>
Thu, 14 Sep 2023 11:57:01 +0000 (13:57 +0200)
bacula/src/filed/job.c
bacula/src/win32/compat/compat.cpp
bacula/src/win32/compat/winapi.h
bacula/src/win32/filed/vss.h

index a719feae2dffd92274683bd392de81cfd36c068b..84e4cf49fd73d94fe874aa31ef44dd917f6d3f66 100644 (file)
@@ -2277,7 +2277,7 @@ static void list_drives(findFILESET *fileset, dlist *name_list, MTab *mtab)
          if (is_excluded(fileset, buf, true)) {
             continue; /* the name is in the exclude list */
          }
-         remove_win32_trailing_slash(buf);
+         strip_trailing_slashes(buf);
          /* add the name without the ending '/' */
          Dmsg1(DT_VOLUME|50,"Adding drive in include list %s\n",buf);
          name_list->append(new_dlistString(buf));
@@ -2341,7 +2341,7 @@ get_win32_driveletters(JCR *jcr, FF_PKT *ff, char* szDrives, void* mtab_def)
          drive[0] = szDrives[i];
          if (mtab->addInSnapshotSet(drive)) { /* When all volumes are selected, we can stop */
             Dmsg0(DT_VOLUME|50, "All Volumes are marked, stopping the loop here\n");
-            goto all_included;  // TODO ASX I don't like this goto, I would prefer a break
+            goto all_included;
          }
       }
    }
@@ -2363,7 +2363,7 @@ get_win32_driveletters(JCR *jcr, FF_PKT *ff, char* szDrives, void* mtab_def)
             if (mtab->addInSnapshotSet(fname)) {
                /* When all volumes are selected, we can stop */
                Dmsg0(DT_VOLUME|50, "All Volumes are marked, stopping the loop here\n");
-               goto all_included;  // TODO ASX I don't like this goto, I would prefer a break
+               goto all_included;
             }
          }
       }
@@ -2383,21 +2383,12 @@ get_win32_driveletters(JCR *jcr, FF_PKT *ff, char* szDrives, void* mtab_def)
          int len;
 
          Dmsg0(DT_VOLUME|50, "OneFS is set, looking for remaining volumes\n");
-         mtab->dump(__FILE__, __LINE__, DT_VOLUME|50, "ASX mtab: ");
+         mtab->dump(__FILE__, __LINE__, DT_VOLUME|50, "mtab: ");
 
          foreach_rblist(elt, mtab->entries) {
             if (elt->in_SnapshotSet) {
                Dmsg1(DT_VOLUME|50, "Skip volume that is already in the snapshot list: %ls\n", elt->first());
                continue;         /* Was already selected in the Include list */
-               /* ASX We should not do that
-                * imaginons qu'un volume soit monté sur C:/mnt et F:/ en meme temps
-                * et qu'on a File=C:/, dans ce cas C:/ et c/mnt sont backupé
-                * plus tard l'utilisateur ajoute File=F:/toto
-                * ce dernier va forcer le snapshot sur le volume en question
-                * et du coups C:/mnt ne sera plus considéré et donc non backupé
-                * si on inclu aussi C:/mnt, on aura 2x toto
-                * on devrait pas faire un continue ici
-                */
             }
             /* A volume can have multiple mount points */
             for (wchar_t *p = elt->first() ; p && *p ; p = elt->next(p)) {
@@ -2468,7 +2459,7 @@ get_win32_driveletters(JCR *jcr, FF_PKT *ff, char* szDrives, void* mtab_def)
                   /* We can add the current volume to the FileSet */
                   if (inc != NULL) {
                      dlistString *tmp = new_dlistString(fn);
-                     remove_win32_trailing_slash(tmp->c_str()); /* remove the trailing slash */
+                     strip_trailing_slashes(tmp->c_str());
                      inc->name_list.append(tmp);
                      Dmsg1(DT_VOLUME|50,"Adding volume in file list %s\n", fn);
                      elt->setInSnapshotSet();
index 747e050240bae0f63dea2d399795d5ca7d8c500b..55407228d89f29b8a938d1a8619addeb9f4e5f10 100644 (file)
@@ -662,15 +662,6 @@ void win32_to_unix_slash(char *name)
    }
 }
 
-/* remove the trailing slashes if any */
-void remove_win32_trailing_slash(char *name)
-{
-   int l = strlen(name);
-   while (l > 0 && (name[l-1] == '/' || name[l-1] == '\\')) {
-      name[--l]='\0';
-   }
-}
-
 /*
  * Convert a WUTF8 path into a normalized wchar windows path
  * Get the result from cache
index 8093924ed678bfa81048aa13ae51a57dd6eed821..ed58d651a7b4b0dbb47ecc9517dc5bd48318410e 100644 (file)
@@ -55,7 +55,6 @@ int wutf8_path_2_wchar(POOLMEM **ppszUCS, const char *pszUTF);
 int UTF8_2_wchar(POOLMEM **pszUCS, const char *pszUTF);
 int make_win32_path_UTF8_2_wchar(POOLMEM **pszUCS, const char *pszUTF, BOOL* pBIsRawPath = NULL);
 void win32_to_unix_slash(char *name);
-void remove_win32_trailing_slash(char *name);
 
 // init with win9x, but maybe set to NT in InitWinAPI
 extern DWORD DLL_IMP_EXP g_platform_id;
index 38cd21ced12a966528b788d701adf4c201018153..c201b07cb4be8ed83d0b507661026145e53122be 100644 (file)
@@ -74,6 +74,8 @@ private:
     virtual void QuerySnapshotSet(GUID snapshotSetID) = 0;
 
 protected:
+    /* On windows, we control the Compiler version and we can use C++11
+       in-member class initializers */
     JCR       *m_jcr = NULL;
 
     DWORD      m_dwContext = 0;