From a6992dd89eb99d9213f462b91479414bcd7bd63e Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 29 Mar 2019 20:49:30 +0000 Subject: Tidy fixes for latest clang --- libadhocutil/curlMultiHandle.cpp | 1 + libadhocutil/curlStream.cpp | 1 + libadhocutil/fileUtils.cpp | 1 + libadhocutil/processPipes.cpp | 20 +++++++++++--------- libadhocutil/runtimeContext.cpp | 1 + libadhocutil/unittests/Jamfile.jam | 5 +++++ libadhocutil/uriParse.cpp | 5 ++--- 7 files changed, 22 insertions(+), 12 deletions(-) diff --git a/libadhocutil/curlMultiHandle.cpp b/libadhocutil/curlMultiHandle.cpp index ac40b49..65e9464 100644 --- a/libadhocutil/curlMultiHandle.cpp +++ b/libadhocutil/curlMultiHandle.cpp @@ -4,6 +4,7 @@ #include "runtimeContext.h" #include "curlStream.h" +// NOLINTNEXTLINE(modernize-concat-nested-namespaces) namespace AdHoc { namespace Net { diff --git a/libadhocutil/curlStream.cpp b/libadhocutil/curlStream.cpp index 69f04f0..3fb441f 100644 --- a/libadhocutil/curlStream.cpp +++ b/libadhocutil/curlStream.cpp @@ -1,5 +1,6 @@ #include "curlStream.h" +// NOLINTNEXTLINE(modernize-concat-nested-namespaces) namespace AdHoc { namespace Net { diff --git a/libadhocutil/fileUtils.cpp b/libadhocutil/fileUtils.cpp index 4e7b809..f54189f 100644 --- a/libadhocutil/fileUtils.cpp +++ b/libadhocutil/fileUtils.cpp @@ -5,6 +5,7 @@ #include #include +// NOLINTNEXTLINE(modernize-concat-nested-namespaces) namespace AdHoc { namespace FileUtils { AdHocFormatter(FD, "FD %?"); diff --git a/libadhocutil/processPipes.cpp b/libadhocutil/processPipes.cpp index f968fab..90e6d14 100644 --- a/libadhocutil/processPipes.cpp +++ b/libadhocutil/processPipes.cpp @@ -7,14 +7,16 @@ #include #include "scopeExit.h" +// NOLINTNEXTLINE(modernize-concat-nested-namespaces) namespace AdHoc { namespace System { +using PipePair = std::array; static void -pipe(int pipes[2], ScopeExit & tidyUp) +pipe(PipePair & pipes, ScopeExit & tidyUp) { - if (::pipe(pipes)) { + if (::pipe(pipes.data())) { throw SystemException("pipe(2) failed", strerror(errno), errno); } tidyUp.onFailure.emplace_back([pipes] { @@ -31,16 +33,16 @@ ProcessPipes::ProcessPipes(const std::vector & args, bool i, bool o if (args.empty()) { throw std::invalid_argument("args is empty"); } - std::array ipipes { -1, -1 }, opipes { -1, -1 }, epipes { -1, -1 }; + PipePair ipipes { -1, -1 }, opipes { -1, -1 }, epipes { -1, -1 }; ScopeExit tidyUp; if (i) { - pipe(ipipes.data(), tidyUp); + pipe(ipipes, tidyUp); } if (o) { - pipe(opipes.data(), tidyUp); + pipe(opipes, tidyUp); } if (e) { - pipe(epipes.data(), tidyUp); + pipe(epipes, tidyUp); } switch (child = fork()) { case -1: // fail @@ -73,14 +75,14 @@ ProcessPipes::ProcessPipes(const std::vector & args, bool i, bool o dup2(epipes[1], 2); } closeAllOpenFiles(); - char * buf[100]; - char ** w = &buf[0]; + std::vector buf(args.size() + 1); + auto w = buf.begin(); for (const auto & p : args) { *w++ = strdup(p.c_str()); } *w = nullptr; if (buf[0]) { - execv(buf[0], (char * const *)buf); + execv(buf[0], buf.data()); } abort(); break; diff --git a/libadhocutil/runtimeContext.cpp b/libadhocutil/runtimeContext.cpp index 8d3aeea..6b31743 100644 --- a/libadhocutil/runtimeContext.cpp +++ b/libadhocutil/runtimeContext.cpp @@ -3,6 +3,7 @@ #include #include +// NOLINTNEXTLINE(modernize-concat-nested-namespaces) namespace AdHoc { namespace System { diff --git a/libadhocutil/unittests/Jamfile.jam b/libadhocutil/unittests/Jamfile.jam index 02a9275..6b04540 100644 --- a/libadhocutil/unittests/Jamfile.jam +++ b/libadhocutil/unittests/Jamfile.jam @@ -19,6 +19,11 @@ lib stdc++fs ; lib pthread ; lib dl ; +project + : requirements + tidy:misc-non-private-member-variables-in-classes + ; + h lorem-ipsum : lorem-ipsum.txt ; run diff --git a/libadhocutil/uriParse.cpp b/libadhocutil/uriParse.cpp index 2d8a557..ba507c8 100644 --- a/libadhocutil/uriParse.cpp +++ b/libadhocutil/uriParse.cpp @@ -14,7 +14,6 @@ namespace AdHoc { { auto * puri = this; const char *curstr; - int i; int userpass_flag; int bracket_flag; @@ -24,8 +23,8 @@ namespace AdHoc { if (!tmpstr) { throw InvalidUri("Schema marker not found", uri); } - int len = tmpstr - curstr; - for (i = 0; i < len; i++) { + auto len = tmpstr - curstr; + for (decltype(len) i = 0; i < len; i++) { if (!_is_scheme_char(curstr[i])) { throw InvalidUri("Invalid format", uri); } -- cgit v1.2.3