Commit 095735fa authored by Albert Astals Cid's avatar Albert Astals Cid

Enable clang-tidy bugprone-too-small-loop-variable

And fixes for it in the code
parent f92b2858
Pipeline #67945 passed with stage
in 10 minutes and 17 seconds
......@@ -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
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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)
......
......@@ -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;
......
......@@ -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)
......
......@@ -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();
}
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment