]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
metaplugin: Refactor simple sscanf.
authorRadosław Korzeniewski <radekk@inteos.pl>
Fri, 8 Jan 2021 14:29:27 +0000 (15:29 +0100)
committerEric Bollengier <eric@baculasystems.com>
Thu, 24 Mar 2022 08:03:00 +0000 (09:03 +0100)
bacula/src/plugins/fd/pluginlib/metaplugin.cpp
bacula/src/plugins/fd/pluginlib/metaplugin.h

index fedb0876882bd7acd270dc671d7240cc92d5d6b1..18d9d566705afdddd8f09eb076a5b89d31f57911 100644 (file)
@@ -163,7 +163,7 @@ METAPLUGIN::METAPLUGIN(bpContext *bpctx) :
       readxattr(false),
       accurate_warning(false),
       fname(PM_FNAME),
-      lname(NULL),
+      lname(PM_FNAME),
       robjbuf(NULL),
       plugin_obj_cat(PM_FNAME),
       plugin_obj_type(PM_FNAME),
@@ -192,7 +192,6 @@ METAPLUGIN::METAPLUGIN(bpContext *bpctx) :
 METAPLUGIN::~METAPLUGIN()
 {
    /* free standard variables */
-   free_and_null_pool_memory(lname);
    free_and_null_pool_memory(robjbuf);
 }
 
@@ -1829,7 +1828,6 @@ bRC METAPLUGIN::setPluginValue(bpContext *ctx, pVariable var, void *value)
 bRC METAPLUGIN::startBackupFile(bpContext *ctx, struct save_pkt *sp)
 {
    POOL_MEM cmd(PM_FNAME);
-   POOL_MEM tmp(PM_FNAME);
    char type;
    size_t size;
    int uid, gid;
@@ -1877,11 +1875,6 @@ bRC METAPLUGIN::startBackupFile(bpContext *ctx, struct save_pkt *sp)
       // here we handle standard metadata
       reqparams--;
 
-      /* we require lname */
-      if (!lname){
-         lname = get_pool_memory(PM_FNAME);
-      }
-
       while (backend.ctx->read_command(ctx, cmd) > 0)
       {
          DMSG(ctx, DINFO, "read_command(2): %s\n", cmd.c_str());
@@ -1921,13 +1914,14 @@ bRC METAPLUGIN::startBackupFile(bpContext *ctx, struct save_pkt *sp)
             DMSG3(ctx, DINFO, "TSTAMP:%ld(at) %ld(mt) %ld(ct)\n", sp->statp.st_atime, sp->statp.st_mtime, sp->statp.st_ctime);
             continue;
          }
-         if (bsscanf(cmd.c_str(), "LSTAT:%s", lname) == 1)
+         if (scan_parameter_str(cmd, "LSTAT:", lname) == 1)
          {
-            sp->link = lname;
+            sp->link = lname.c_str();
             reqparams--;
-            DMSG(ctx, DINFO, "LSTAT:%s\n", lname);
+            DMSG(ctx, DINFO, "LSTAT:%s\n", lname.c_str());
             continue;
          }
+         POOL_MEM tmp(PM_FNAME);
          if (scan_parameter_str(cmd, "PIPE:", tmp)){
             /* handle PIPE command */
             DMSG(ctx, DINFO, "read pipe at: %s\n", tmp.c_str());
index 9b034ff5bed95aa0ee64bd0f3c0ab4c00441cb7e..59fabad6ff1f4b1fb7f3ac8efa9683ca86b04af7 100644 (file)
@@ -131,7 +131,7 @@ private:
    bool accurate_warning;        // for sending accurate mode warning once */
    COMMCTX<PTCOMM> backend;      // the backend context list for multiple backend execution for a single job
    POOL_MEM fname;               // current file name to backup (grabbed from backend)
-   POOLMEM *lname;               // current LSTAT data if any
+   POOL_MEM lname;               // current LSTAT data if any
    POOLMEM *robjbuf;             // the buffer for restore object data
    POOL_MEM plugin_obj_cat;      // Plugin object Category
    POOL_MEM plugin_obj_type;     // Plugin object Type