Tim Landscheidt has uploaded a new change for review.
https://gerrit.wikimedia.org/r/268934
Change subject: Make take's FD constructor explicit
......................................................................
Make take's FD constructor explicit
cppcheck complained:
| [src/take.cc:41]: (style) Struct 'FD' has a constructor with 1
| argument that is not explicit. Such constructors should in general
| be explicit for type safety reasons. Using the explicit keyword in
| the constructor means some mistakes when using the class can be
| avoided.
This change makes the constructor explicit.
Change-Id: I72d27544833e778385ea1872c855bd73993c3983
---
M debian/changelog
M src/take.cc
2 files changed, 3 insertions(+), 2 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/labs/toollabs
refs/changes/34/268934/1
diff --git a/debian/changelog b/debian/changelog
index b54d86f..df78ef6 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,5 +1,6 @@
toollabs (1.9~dev) unstable; urgency=medium
+ * Make take's FD constructor explicit. [Tim Landscheidt]
* Add options --help and --version to take. [Platonides]
* Don't call log-command-invocation when testing jsub. [Bryan Davis]
* Set versions and dates in man pages from debian/changelog. [Tim
diff --git a/src/take.cc b/src/take.cc
index 96e3e98..89b51e2 100755
--- a/src/take.cc
+++ b/src/take.cc
@@ -38,7 +38,7 @@
struct FD {
int fd;
- FD(int f): fd(f) { };
+ explicit FD(int f): fd(f) { };
~FD() { if(fd >= 0)
close(fd); };
operator int (void) const { return fd; };
};
@@ -51,7 +51,7 @@
{
// We open the files and use the file descriptors exclusively
// to avoid trickery and race conditions
- FD file = open(path, O_RDONLY|O_NOFOLLOW);
+ FD file = FD(open(path, O_RDONLY|O_NOFOLLOW));
if(file < 0) {
if(errno == ELOOP)
--
To view, visit https://gerrit.wikimedia.org/r/268934
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I72d27544833e778385ea1872c855bd73993c3983
Gerrit-PatchSet: 1
Gerrit-Project: labs/toollabs
Gerrit-Branch: master
Gerrit-Owner: Tim Landscheidt <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits