summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/cdromutl.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2017-12-13 23:54:38 +0100
committerDavid Kalnischkies <david@kalnischkies.de>2017-12-13 23:54:38 +0100
commit99813a2eaa7c0cce1d7d8c811827733ed66458de (patch)
tree61fe422eeca8c5bd5cb2de6060f11e71343d4602 /apt-pkg/contrib/cdromutl.cc
parentd30b30ad1e1ce434df84e15e2573c43ac152f9e3 (diff)
parent0b5e329a8ba2461ccb7017d3adfc972f9dccd830 (diff)
Merge branch 'feature/happy-gcc'
Fixing various real and imagined bugs reported by gcc warnings
Diffstat (limited to 'apt-pkg/contrib/cdromutl.cc')
-rw-r--r--apt-pkg/contrib/cdromutl.cc33
1 files changed, 14 insertions, 19 deletions
diff --git a/apt-pkg/contrib/cdromutl.cc b/apt-pkg/contrib/cdromutl.cc
index 93bfb9f42..7ae54060a 100644
--- a/apt-pkg/contrib/cdromutl.cc
+++ b/apt-pkg/contrib/cdromutl.cc
@@ -105,13 +105,14 @@ bool UnmountCdrom(string Path)
}
else
{
- const char *Args[10];
- Args[0] = "umount";
- Args[1] = Path.c_str();
- Args[2] = 0;
- execvp(Args[0],(char **)Args);
+ const char * const Args[] = {
+ "umount",
+ Path.c_str(),
+ nullptr
+ };
+ execvp(Args[0], const_cast<char **>(Args));
_exit(100);
- }
+ }
}
// if it can not be umounted, give it a bit more time
@@ -222,15 +223,13 @@ bool IdentCdrom(string CD,string &Res,unsigned int Version)
std::string S;
if (Version <= 1)
- {
- strprintf(S, "%lu", (unsigned long)Dir->d_ino);
- }
+ S = std::to_string(Dir->d_ino);
else
{
struct stat Buf;
if (fstatat(dirfd, Dir->d_name, &Buf, 0) != 0)
continue;
- strprintf(S, "%lu", (unsigned long)Buf.st_mtime);
+ S = std::to_string(Buf.st_mtime);
}
Hash.Add(S.c_str());
@@ -246,21 +245,17 @@ bool IdentCdrom(string CD,string &Res,unsigned int Version)
return _error->Errno("statfs",_("Failed to stat the cdrom"));
// We use a kilobyte block size to avoid overflow
- if (writable_media)
- {
- strprintf(S, "%lu", (unsigned long)(Buf.f_blocks*(Buf.f_bsize/1024)));
- } else {
- strprintf(S, "%lu %lu", (unsigned long)(Buf.f_blocks*(Buf.f_bsize/1024)),
- (unsigned long)(Buf.f_bfree*(Buf.f_bsize/1024)));
- }
- Hash.Add(S.c_str());
+ S = std::to_string(Buf.f_blocks * (Buf.f_bsize / 1024));
+ if (writable_media == false)
+ S.append(" ").append(std::to_string(Buf.f_bfree * (Buf.f_bsize / 1024)));
+ Hash.Add(S.c_str(), S.length());
strprintf(S, "-%u", Version);
}
else
strprintf(S, "-%u.debug", Version);
closedir(D);
- Res = Hash.Result().Value() + S;
+ Res = Hash.Result().Value().append(std::move(S));
return true;
}
/*}}}*/