From: Radosław Korzeniewski Date: Fri, 8 Jan 2021 14:29:27 +0000 (+0100) Subject: metaplugin: Refactor simple sscanf. X-Git-Tag: Release-11.3.2~723 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=544a10795de214bbb80fda3a8c6bca646aaee3cb;p=thirdparty%2Fbacula.git metaplugin: Refactor simple sscanf. --- diff --git a/bacula/src/plugins/fd/pluginlib/metaplugin.cpp b/bacula/src/plugins/fd/pluginlib/metaplugin.cpp index fedb08768..18d9d5667 100644 --- a/bacula/src/plugins/fd/pluginlib/metaplugin.cpp +++ b/bacula/src/plugins/fd/pluginlib/metaplugin.cpp @@ -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()); diff --git a/bacula/src/plugins/fd/pluginlib/metaplugin.h b/bacula/src/plugins/fd/pluginlib/metaplugin.h index 9b034ff5b..59fabad6f 100644 --- a/bacula/src/plugins/fd/pluginlib/metaplugin.h +++ b/bacula/src/plugins/fd/pluginlib/metaplugin.h @@ -131,7 +131,7 @@ private: bool accurate_warning; // for sending accurate mode warning once */ COMMCTX 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