.gitlab-ci.yml | 2 +- cpp/tests/poppler-dump.cpp | 4 ++-- glib/poppler-document.cc | 2 +- poppler/Form.cc | 6 +++--- poppler/PSOutputDev.cc | 6 +++--- poppler/StructElement.cc | 4 ++-- qt5/src/poppler-document.cc | 4 ++-- splash/SplashXPathScanner.cc | 6 +++--- 8 files changed, 17 insertions(+), 17 deletions(-)
New commits: commit 095735fa1259a030da8c854ee8ff649fe907642d Author: Albert Astals Cid <[email protected]> Date: Wed Oct 2 17:50:42 2019 +0200 Enable clang-tidy bugprone-too-small-loop-variable And fixes for it in the code diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 71b4e5cc..42bdb899 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -40,7 +40,7 @@ build_clang_libcpp: script: - git clone --branch ${CI_COMMIT_REF_NAME} --depth 1 ${TEST_DATA_URL} test-data || git clone --depth 1 ${UPSTREAM_TEST_DATA_URL} test-data - mkdir -p build && cd build - - CC=clang CXX=clang++ cmake -G Ninja -DCMAKE_CXX_FLAGS=-stdlib=libc++ -DTESTDATADIR=$PWD/../test-data -DCMAKE_CXX_CLANG_TIDY="clang-tidy;-header-filter=.;-checks=-*,performance-*;-warnings-as-errors=*" .. + - CC=clang CXX=clang++ cmake -G Ninja -DCMAKE_CXX_FLAGS=-stdlib=libc++ -DTESTDATADIR=$PWD/../test-data -DCMAKE_CXX_CLANG_TIDY="clang-tidy;-header-filter=.;-checks=-*,performance-*,bugprone-too-small-loop-variable;-warnings-as-errors=*" .. - ninja - ctest --output-on-failure diff --git a/cpp/tests/poppler-dump.cpp b/cpp/tests/poppler-dump.cpp index cdd515d3..395802be 100644 --- a/cpp/tests/poppler-dump.cpp +++ b/cpp/tests/poppler-dump.cpp @@ -103,8 +103,8 @@ static void error(const std::string &msg) static std::ostream& operator<<(std::ostream& stream, const poppler::ustring &str) { const poppler::byte_array ba = str.to_utf8(); - for (unsigned int i = 0; i < ba.size(); ++i) { - stream << (char)(ba[i]); + for (const char c : ba) { + stream << c; } return stream; } diff --git a/glib/poppler-document.cc b/glib/poppler-document.cc index 843be835..fbeaf34d 100644 --- a/glib/poppler-document.cc +++ b/glib/poppler-document.cc @@ -1829,7 +1829,7 @@ poppler_document_get_print_page_ranges (PopplerDocument *document, *n_ranges = ranges.size (); result = g_new (PopplerPageRange, ranges.size ()); - for (guint i = 0; i < ranges.size (); ++i) { + for (size_t i = 0; i < ranges.size (); ++i) { result[i].start_page = ranges[i].first; result[i].end_page = ranges[i].second; } diff --git a/poppler/Form.cc b/poppler/Form.cc index b1231e19..07521526 100644 --- a/poppler/Form.cc +++ b/poppler/Form.cc @@ -585,7 +585,7 @@ GooString* FormWidgetSignature::getCheckedSignature(Goffset *checkedFileSize) } if (sigLen > 0 && 2*(sigLen+lenBytes) <= len-4) { - for (int i = 2*(sigLen+lenBytes)+4; i < len; ++i) + for (Goffset i = 2*(sigLen+lenBytes)+4; i < len; ++i) { if (gstr.getChar(i) != '0') { @@ -598,9 +598,9 @@ GooString* FormWidgetSignature::getCheckedSignature(Goffset *checkedFileSize) len = 0; } } - for (int i = 0; i < len; ++i) + for ( const char c : gstr.toStr() ) { - if (!isxdigit(gstr.getChar(i))) + if (!isxdigit(c)) len = 0; } if (len > 0) diff --git a/poppler/PSOutputDev.cc b/poppler/PSOutputDev.cc index 52fd8223..1302e4ee 100644 --- a/poppler/PSOutputDev.cc +++ b/poppler/PSOutputDev.cc @@ -1547,7 +1547,7 @@ void PSOutputDev::writeHeader(int nPages, } if(title) { char *sanitizedTitle = strdup(title); - for (unsigned int i = 0; i < strlen(sanitizedTitle); ++i) { + for (size_t i = 0; i < strlen(sanitizedTitle); ++i) { if (sanitizedTitle[i] == '\n' || sanitizedTitle[i] == '\r') { sanitizedTitle[i] = ' '; } @@ -2108,8 +2108,8 @@ void PSOutputDev::setupFont(GfxFont *font, Dict *parentResDict) { void PSOutputDev::setupEmbeddedType1Font(Ref *id, GooString *psName) { static const char hexChar[17] = "0123456789abcdef"; Dict *dict; - long length1, length2, length3; - int c, i; + long length1, length2, length3, i; + int c; int start[4]; bool binMode; bool writePadding = true; diff --git a/poppler/StructElement.cc b/poppler/StructElement.cc index 3ad314ce..cdfb3c2f 100644 --- a/poppler/StructElement.cc +++ b/poppler/StructElement.cc @@ -471,9 +471,9 @@ static const struct OwnerMapEntry { static bool ownerHasMorePriority(Attribute::Owner a, Attribute::Owner b) { - unsigned aIndex, bIndex; + size_t aIndex, bIndex, i; - for (unsigned i = aIndex = bIndex = 0; i < sizeof(ownerMap) / sizeof(ownerMap[0]); i++) { + for (i = aIndex = bIndex = 0; i < sizeof(ownerMap) / sizeof(ownerMap[0]); i++) { if (ownerMap[i].owner == a) aIndex = i; if (ownerMap[i].owner == b) diff --git a/qt5/src/poppler-document.cc b/qt5/src/poppler-document.cc index 9443b3e2..ba9b86cd 100644 --- a/qt5/src/poppler-document.cc +++ b/qt5/src/poppler-document.cc @@ -806,8 +806,8 @@ namespace Poppler { Form *form = m_doc->doc->getCatalog()->getForm(); const std::vector<Ref> &calculateOrder = form->getCalculateOrder(); - for (uint i = 0; i < calculateOrder.size(); ++i) { - FormWidget *w = form->findWidgetByRef(calculateOrder[i]); + for (Ref r : calculateOrder) { + FormWidget *w = form->findWidgetByRef(r); if (w) { result << w->getID(); } diff --git a/splash/SplashXPathScanner.cc b/splash/SplashXPathScanner.cc index 042a6ef6..4ca90bc2 100644 --- a/splash/SplashXPathScanner.cc +++ b/splash/SplashXPathScanner.cc @@ -129,9 +129,9 @@ void SplashXPathScanner::getSpanBounds(int y, int *spanXMin, int *spanXMax) { if (!line.empty()) { *spanXMin = line[0].x0; int xx = line[0].x1; - for (unsigned int i = 1; i < line.size(); ++i) { - if (line[i].x1 > xx) { - xx = line[i].x1; + for (const SplashIntersect &intersect : line) { + if (intersect.x1 > xx) { + xx = intersect.x1; } } *spanXMax = xx; _______________________________________________ poppler mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/poppler
