mnt: simpler describeMountPt
authorRobert Swiecki <robert@swiecki.net>
Tue, 20 Feb 2018 15:03:32 +0000 (16:03 +0100)
committerRobert Swiecki <robert@swiecki.net>
Tue, 20 Feb 2018 15:03:32 +0000 (16:03 +0100)
mnt.cc

diff --git a/mnt.cc b/mnt.cc
index 9b3e1a1..30e26a5 100644 (file)
--- a/mnt.cc
+++ b/mnt.cc
@@ -522,25 +522,36 @@ bool addMountPtTail(nsjconf_t* nsjconf, const std::string& src, const std::strin
 }
 
 const std::string describeMountPt(const mount_t& mpt) {
-       char mount_pt_descr[256];
-
-       snprintf(mount_pt_descr, sizeof(mount_pt_descr),
-           "src:'%s' dst:'%s' type:'%s' flags:%s options:'%s' isDir:%s", mpt.src.c_str(),
-           mpt.dst.c_str(), mpt.fs_type.c_str(), flagsToStr(mpt.flags).c_str(),
-           mpt.options.c_str(), mpt.is_dir ? "true" : "false");
+       std::string descr;
+
+       descr.append("src:'")
+           .append(mpt.src)
+           .append("' dst:'")
+           .append(mpt.dst)
+           .append("' flags:'")
+           .append(flagsToStr(mpt.flags))
+           .append("' type:'")
+           .append(mpt.fs_type)
+           .append("' options:'")
+           .append(mpt.options)
+           .append("'");
+       if (mpt.is_dir) {
+               descr.append(" is_dir:true");
+       } else {
+               descr.append(" is_dir:false");
+       }
 
        if (!mpt.is_mandatory) {
-               util::sSnPrintf(mount_pt_descr, sizeof(mount_pt_descr), " mandatory:false");
+               descr.append(" mandatory:false");
        }
        if (!mpt.src_content.empty()) {
-               util::sSnPrintf(mount_pt_descr, sizeof(mount_pt_descr), " src_content_len:%zu",
-                   mpt.src_content.length());
+               descr.append(" src_content_len:").append(std::to_string(mpt.src_content.length()));
        }
        if (mpt.is_symlink) {
-               util::sSnPrintf(mount_pt_descr, sizeof(mount_pt_descr), " symlink:true");
+               descr.append(" symlink:true");
        }
 
-       return mount_pt_descr;
+       return descr;
 }
 
 }  // namespace mnt