From b2cc12473d99caca3f3ceb5244f67fe3579fdd5f Mon Sep 17 00:00:00 2001 From: Arvin Schnell Date: Tue, 17 Nov 2020 12:38:08 +0100 Subject: [PATCH] - renamed SystemCmd::stdout/stderr to avoid conflict with defines --- client/misc.cc | 5 +++-- snapper/Lvm.cc | 5 +++-- snapper/LvmCache.cc | 22 +++++++++++----------- snapper/SystemCmd.h | 6 +++--- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/client/misc.cc b/client/misc.cc index 638e6cbf..beb35e72 100644 --- a/client/misc.cc +++ b/client/misc.cc @@ -1,5 +1,6 @@ /* * Copyright (c) [2011-2014] Novell, Inc. + * Copyright (c) 2020 SUSE LLC * * All Rights Reserved. * @@ -179,9 +180,9 @@ Differ::run(const string& f1, const string& f2) const SystemCmd cmd(tmp); - for (const string& line : cmd.stdout()) + for (const string& line : cmd.get_stdout()) cout << line << endl; - for (const string& line : cmd.stderr()) + for (const string& line : cmd.get_stderr()) cerr << line << endl; } diff --git a/snapper/Lvm.cc b/snapper/Lvm.cc index 3a97b829..2a452707 100644 --- a/snapper/Lvm.cc +++ b/snapper/Lvm.cc @@ -1,5 +1,6 @@ /* * Copyright (c) [2011-2014] Novell, Inc. + * Copyright (c) 2020 SUSE LLC * * All Rights Reserved. * @@ -467,7 +468,7 @@ namespace snapper { SystemCmd cmd(string(LVMBIN " version")); - if (cmd.retcode() != 0 || cmd.stdout().empty()) + if (cmd.retcode() != 0 || cmd.get_stdout().empty()) { y2war("Couldn't get LVM version info"); } @@ -475,7 +476,7 @@ namespace snapper { Regex rx(".*LVM[[:space:]]+version:[[:space:]]+([0-9]+)\\.([0-9]+)\\.([0-9]+).*$"); - if (!rx.match(cmd.stdout().front())) + if (!rx.match(cmd.get_stdout().front())) { y2war("LVM version format didn't match"); } diff --git a/snapper/LvmCache.cc b/snapper/LvmCache.cc index f610b608..3d5c92fe 100644 --- a/snapper/LvmCache.cc +++ b/snapper/LvmCache.cc @@ -1,5 +1,6 @@ /* * Copyright (c) [2013] Red Hat, Inc. + * Copyright (c) 2020 SUSE LLC * * All Rights Reserved. * @@ -15,7 +16,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * */ #include "config.h" @@ -143,14 +143,14 @@ namespace snapper boost::unique_lock unique_lock(lv_mutex); SystemCmd cmd(LVSBIN " --noheadings -o lv_attr,segtype " + quote(vg->get_vg_name() + "/" + lv_name)); - if (cmd.retcode() != 0 || cmd.stdout().empty()) + if (cmd.retcode() != 0 || cmd.get_stdout().empty()) { y2err("lvm cache: failed to get info about " << vg->get_vg_name() << "/" << lv_name); throw LvmCacheException(); } vector args; - const string tmp = boost::trim_copy(cmd.stdout().front()); + const string tmp = boost::trim_copy(cmd.get_stdout().front()); boost::split(args, tmp, boost::is_any_of(" \t\n"), boost::token_compress_on); if (args.size() < 1) throw LvmCacheException(); @@ -180,7 +180,7 @@ namespace snapper VolumeGroup::VolumeGroup(vg_content_raw& input, const string& vg_name, const string& add_lv_name) : vg_name(vg_name) { - for (vg_content_raw::const_iterator cit = input.begin(); cit != input.end(); cit++) + for (vg_content_raw::const_iterator cit = input.begin(); cit != input.end(); ++cit) if (cit->first == add_lv_name || cit->first.find("-snapshot") != string::npos) lv_info_map.insert(make_pair(cit->first, new LogicalVolume(this, cit->first, LvAttrs(cit->second)))); } @@ -188,7 +188,7 @@ namespace snapper VolumeGroup::~VolumeGroup() { - for (const_iterator cit = lv_info_map.begin(); cit != lv_info_map.end(); cit++) + for (const_iterator cit = lv_info_map.begin(); cit != lv_info_map.end(); ++cit) delete cit->second; } @@ -282,14 +282,14 @@ namespace snapper else { SystemCmd cmd(LVSBIN " --noheadings -o lv_attr,segtype " + quote(vg_name + "/" + lv_name)); - if (cmd.retcode() != 0 || cmd.stdout().empty()) + if (cmd.retcode() != 0 || cmd.get_stdout().empty()) { y2err("lvm cache: failed to get info about " << vg_name << "/" << lv_name); throw LvmCacheException(); } vector args; - const string tmp = boost::trim_copy(cmd.stdout().front()); + const string tmp = boost::trim_copy(cmd.get_stdout().front()); boost::split(args, tmp, boost::is_any_of(" \t\n"), boost::token_compress_on); if (args.size() < 1) throw LvmCacheException(); @@ -332,7 +332,7 @@ namespace snapper // do not allow any modifications in a whole VG boost::unique_lock unique_lock(vg_mutex); - for (const_iterator cit = lv_info_map.begin(); cit != lv_info_map.end(); cit++) + for (const_iterator cit = lv_info_map.begin(); cit != lv_info_map.end(); ++cit) out << "\tLV:'" << cit->first << "':" << std::endl << "\t\t" << cit->second; } @@ -347,7 +347,7 @@ namespace snapper LvmCache::~LvmCache() { - for (const_iterator cit = vgroups.begin(); cit != vgroups.end(); cit++) + for (const_iterator cit = vgroups.begin(); cit != vgroups.end(); ++cit) delete cit->second; } @@ -445,7 +445,7 @@ namespace snapper vg_content_raw new_content; - for (vector::const_iterator cit = cmd.stdout().begin(); cit != cmd.stdout().end(); cit++) + for (vector::const_iterator cit = cmd.get_stdout().begin(); cit != cmd.get_stdout().end(); ++cit) { vector args; @@ -484,7 +484,7 @@ namespace snapper operator<<(std::ostream& out, const LvmCache* cache) { out << "LvmCache:" << std::endl; - for (LvmCache::const_iterator cit = cache->vgroups.begin(); cit != cache->vgroups.end(); cit++) + for (LvmCache::const_iterator cit = cache->vgroups.begin(); cit != cache->vgroups.end(); ++cit) out << "Volume Group:'" << cit->first << "':" << std::endl << cit->second; return out; diff --git a/snapper/SystemCmd.h b/snapper/SystemCmd.h index 3d38604d..21fa32eb 100644 --- a/snapper/SystemCmd.h +++ b/snapper/SystemCmd.h @@ -1,6 +1,6 @@ /* * Copyright (c) [2004-2014] Novell, Inc. - * Copyright (c) 2018 SUSE LLC + * Copyright (c) [2018-2020] SUSE LLC * * All Rights Reserved. * @@ -59,8 +59,8 @@ namespace snapper public: - const vector& stdout() const { return Lines_aC[IDX_STDOUT]; } - const vector& stderr() const { return Lines_aC[IDX_STDERR]; } + const vector& get_stdout() const { return Lines_aC[IDX_STDOUT]; } + const vector& get_stderr() const { return Lines_aC[IDX_STDERR]; } string cmd() const { return lastCmd; } int retcode() const { return Ret_i; } -- 2.47.3