diff --git a/backend/qr.c b/backend/qr.c index 99e09b9b..9bd04bf1 100644 --- a/backend/qr.c +++ b/backend/qr.c @@ -694,15 +694,15 @@ static void add_ecc(unsigned char fullstream[], const unsigned char datastream[] #ifndef _MSC_VER - unsigned char data_block[short_data_block_length + 2]; - unsigned char ecc_block[ecc_block_length + 2]; - unsigned char interleaved_data[data_cw + 2]; - unsigned char interleaved_ecc[ecc_cw + 2]; + unsigned char data_block[short_data_block_length + 1]; + unsigned char ecc_block[ecc_block_length]; + unsigned char interleaved_data[data_cw]; + unsigned char interleaved_ecc[ecc_cw]; #else - data_block = (unsigned char *) _alloca(short_data_block_length + 2); - ecc_block = (unsigned char *) _alloca(ecc_block_length + 2); - interleaved_data = (unsigned char *) _alloca(data_cw + 2); - interleaved_ecc = (unsigned char *) _alloca(ecc_cw + 2); + data_block = (unsigned char *) _alloca(short_data_block_length + 1); + ecc_block = (unsigned char *) _alloca(ecc_block_length); + interleaved_data = (unsigned char *) _alloca(data_cw); + interleaved_ecc = (unsigned char *) _alloca(ecc_cw); #endif posn = 0; @@ -747,7 +747,8 @@ static void add_ecc(unsigned char fullstream[], const unsigned char datastream[] } if (i >= qty_short_blocks) { - interleaved_data[(short_data_block_length * blocks) + (i - qty_short_blocks)] = data_block[short_data_block_length]; + /* NOLINT suppress clang-tidy warning: data_block[short_data_block_length] set for i >= qty_short_blocks */ + interleaved_data[(short_data_block_length * blocks) + (i - qty_short_blocks)] = data_block[short_data_block_length]; // NOLINT } for (j = 0; j < ecc_block_length; j++) { @@ -758,10 +759,10 @@ static void add_ecc(unsigned char fullstream[], const unsigned char datastream[] } for (j = 0; j < data_cw; j++) { - fullstream[j] = interleaved_data[j]; + fullstream[j] = interleaved_data[j]; // NOLINT suppress clang-tidy warning: interleaved_data[data_cw] fully set } for (j = 0; j < ecc_cw; j++) { - fullstream[j + data_cw] = interleaved_ecc[j]; + fullstream[j + data_cw] = interleaved_ecc[j]; // NOLINT suppress clang-tidy warning: interleaved_ecc[ecc_cw] fully set } if (debug & ZINT_DEBUG_PRINT) { @@ -900,7 +901,7 @@ static void populate_grid(unsigned char* grid, const int h_size, const int v_siz n = cw * 8; y = v_size - 1; i = 0; - do { + while (i < n) { int x = (h_size - 2) - (row * 2); if ((x < 6) && (v_size == h_size)) @@ -943,7 +944,7 @@ static void populate_grid(unsigned char* grid, const int h_size, const int v_siz y = v_size - 1; direction = 1; } - } while (i < n); + } } #ifdef ZINTLOG @@ -1071,9 +1072,10 @@ static int evaluate(unsigned char *eval,const int size,const int pattern) { /* Test 2: Block of modules in same color */ for (x = 0; x < size - 1; x++) { for (y = 0; y < size - 1; y++) { - if (((local[(y * size) + x] == local[((y + 1) * size) + x]) && + /* NOLINT suppress clang-tidy warning: local[size * size] fully set */ + if (((local[(y * size) + x] == local[((y + 1) * size) + x]) && // NOLINT (local[(y * size) + x] == local[(y * size) + (x + 1)])) && - (local[(y * size) + x] == local[((y + 1) * size) + (x + 1)])) { + (local[(y * size) + x] == local[((y + 1) * size) + (x + 1)])) { // NOLINT result += 3; } } diff --git a/backend/tests/test_qr.c b/backend/tests/test_qr.c index 0b15f18e..b96b4a56 100644 --- a/backend/tests/test_qr.c +++ b/backend/tests/test_qr.c @@ -92,6 +92,8 @@ static void test_qr_options(void) /* 27*/ { "貫やぐ識禁ぱい再2間変字全ノレ没無8裁花ほゃ過法ひなご札17能つーびれ投覧マ勝動エヨ額界よみ作皇ナヲニ打題ヌルヲ掲布益フが。入35能ト権話しこを断兆モヘ細情おじ名4減エヘイハ側機はょが意見想ハ業独案ユヲウ患職ヲ平美さ毎放どぽたけ家没べお化富べ町大シ情魚ッでれ一冬すぼめり。社ト可化モマ試音ばじご育青康演ぴぎ権型固スで能麩ぜらもほ河都しちほラ収90作の年要とだむ部動ま者断チ第41一1米索焦茂げむしれ。測フ物使だて目月国スリカハ夏検にいへ児72告物ゆは載核ロアメヱ登輸どべゃ催行アフエハ議歌ワ河倫剖だ。記タケウ因載ヒイホヤ禁3輩彦関トえび肝区勝ワリロ成禁ぼよ界白ウヒキレ中島べせぜい各安うしぽリ覧生テ基一でむしゃ中新トヒキソ声碁スしび起田ア信大未ゅもばち。", 1, 22, 0, 0, 105, 0 }, /* 28*/ { "貫やぐ識禁ぱい再2間変字全ノレ没無8裁花ほゃ過法ひなご札17能つーびれ投覧マ勝動エヨ額界よみ作皇ナヲニ打題ヌルヲ掲布益フが。入35能ト権話しこを断兆モヘ細情おじ名4減エヘイハ側機はょが意見想ハ業独案ユヲウ患職ヲ平美さ毎放どぽたけ家没べお化富べ町大シ情魚ッでれ一冬すぼめり。社ト可化モマ試音ばじご育青康演ぴぎ権型固スで能麩ぜらもほ河都しちほラ収90作の年要とだむ部動ま者断チ第41一1米索焦茂げむしれ。測フ物使だて目月国スリカハ夏検にいへ児72告物ゆは載核ロアメヱ登輸どべゃ催行アフエハ議歌ワ河倫剖だ。記タケウ因載ヒイホヤ禁3輩彦関トえび肝区勝ワリロ成禁ぼよ界白ウヒキレ中島べせぜい各安うしぽリ覧生テ基一でむしゃ中新トヒキソ声碁スしび起田ア信大未ゅもばち。", 4, -1, 0, 0, 153, 1 }, // ECC 4, version auto-set 34 /* 29*/ { "貫やぐ識禁ぱい再2間変字全ノレ没無8裁花ほゃ過法ひなご札17能つーびれ投覧マ勝動エヨ額界よみ作皇ナヲニ打題ヌルヲ掲布益フが。入35能ト権話しこを断兆モヘ細情おじ名4減エヘイハ側機はょが意見想ハ業独案ユヲウ患職ヲ平美さ毎放どぽたけ家没べお化富べ町大シ情魚ッでれ一冬すぼめり。社ト可化モマ試音ばじご育青康演ぴぎ権型固スで能麩ぜらもほ河都しちほラ収90作の年要とだむ部動ま者断チ第41一1米索焦茂げむしれ。測フ物使だて目月国スリカハ夏検にいへ児72告物ゆは載核ロアメヱ登輸どべゃ催行アフエハ議歌ワ河倫剖だ。記タケウ因載ヒイホヤ禁3輩彦関トえび肝区勝ワリロ成禁ぼよ界白ウヒキレ中島べせぜい各安うしぽリ覧生テ基一でむしゃ中新トヒキソ声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