mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
#191 clang-tidy reduce NOLINTs using asserts, remove DeadStores
This commit is contained in:
parent
dd2bdb4335
commit
52d08fd9b9
@ -32,7 +32,6 @@
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#ifdef _MSC_VER
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
@ -1579,7 +1578,6 @@ INTERNAL int aztec_runes(struct zint_symbol *symbol, unsigned char source[], int
|
||||
char binary_string[28];
|
||||
unsigned char data_codewords[3], ecc_codewords[6];
|
||||
|
||||
error_number = 0;
|
||||
input_value = 0;
|
||||
if (length > 3) {
|
||||
strcpy(symbol->errtxt, "507: Input too large");
|
||||
|
@ -37,7 +37,7 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#ifndef _MSC_VER
|
||||
#include <stdint.h>
|
||||
@ -322,7 +322,7 @@ static void rsencode(int nd, int nc, unsigned char *wd) {
|
||||
wd[start + i * step] = 0;
|
||||
}
|
||||
for (i = 0; i < ND; i++) {
|
||||
k = (wd[start + i * step] + wd[start + ND * step]) % GF; // NOLINT wd set 0..(nd - 1) and start + i * step <= nd - 1
|
||||
k = (wd[start + i * step] + wd[start + ND * step]) % GF;
|
||||
for (j = 0; j < NC - 1; j++) {
|
||||
wd[start + (ND + j) * step] = (GF - ((c[j + 1] * k) % GF) + wd[start + (ND + j + 1) * step]) % GF;
|
||||
}
|
||||
@ -391,7 +391,7 @@ static int datum_c(const unsigned char source[], int position, int length) {
|
||||
static int n_digits(const unsigned char source[], int position, int length) {
|
||||
int i;
|
||||
|
||||
for (i = position; ((source[i] >= '0') && (source[i] <= '9')) && (i < length); i++);
|
||||
for (i = position; (i < length) && ((source[i] >= '0') && (source[i] <= '9')); i++);
|
||||
|
||||
return i - position;
|
||||
}
|
||||
@ -490,11 +490,7 @@ static int dotcode_encode_message(struct zint_symbol *symbol, const unsigned cha
|
||||
int lawrencium[6]; // Reversed radix 103 values
|
||||
int nx;
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER == 1200
|
||||
uint64_t binary_buffer = 0;
|
||||
#else
|
||||
uint64_t binary_buffer = 0ULL;
|
||||
#endif
|
||||
|
||||
input_position = 0;
|
||||
array_length = 0;
|
||||
@ -1130,7 +1126,7 @@ static size_t make_dotstream(unsigned char masked_array[], int array_length, cha
|
||||
|
||||
/* The rest of the data uses 9-bit dot patterns from Annex C */
|
||||
for (i = 1; i < array_length; i++) {
|
||||
bin_append(dot_patterns[masked_array[i]], 9, dot_stream); // NOLINT masked_array values modulo 113 and fully set
|
||||
bin_append(dot_patterns[masked_array[i]], 9, dot_stream);
|
||||
}
|
||||
|
||||
return strlen(dot_stream);
|
||||
@ -1335,6 +1331,9 @@ INTERNAL int dotcode(struct zint_symbol *symbol, const unsigned char source[], i
|
||||
|
||||
data_length = dotcode_encode_message(symbol, source, length, codeword_array, &binary_finish);
|
||||
|
||||
/* Suppresses clang-tidy clang-analyzer-core.UndefinedBinaryOperatorResult/uninitialized.ArraySubscript warnings */
|
||||
assert(data_length > 0);
|
||||
|
||||
ecc_length = 3 + (data_length / 2);
|
||||
|
||||
if (debug & ZINT_DEBUG_PRINT) {
|
||||
|
@ -34,7 +34,7 @@
|
||||
* and [MS-WMF] - v20160714, Released July 14, 2016 */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#ifdef _MSC_VER
|
||||
#include <malloc.h>
|
||||
@ -634,10 +634,13 @@ INTERNAL int emf_plot(struct zint_symbol *symbol) {
|
||||
fwrite(&emr_selectobject_font, sizeof (emr_selectobject_t), 1, emf_file);
|
||||
}
|
||||
|
||||
/* Suppresses clang-tidy clang-analyzer-core.UndefinedBinaryOperatorResult warning */
|
||||
assert((symbol->vector->strings == NULL && string_count == 0) || (symbol->vector->strings != NULL && string_count > 0));
|
||||
|
||||
for (i = 0; i < string_count; i++) {
|
||||
spacing = 8 * symbol->scale;
|
||||
fwrite(&text[i], sizeof (emr_exttextoutw_t), 1, emf_file);
|
||||
fwrite(this_string[i], bump_up(text[i].w_emr_text.chars + 1) * 2, 1, emf_file); // NOLINT text set 0..(string_count - 1)
|
||||
fwrite(this_string[i], bump_up(text[i].w_emr_text.chars + 1) * 2, 1, emf_file);
|
||||
free(this_string[i]);
|
||||
for (j = 0; j < bump_up(text[i].w_emr_text.chars + 1); j++) {
|
||||
fwrite(&spacing, 4, 1, emf_file);
|
||||
|
@ -34,7 +34,6 @@
|
||||
AIM Global Document Number AIMD014 Rev. 1.63 Revised 9 Dec 2008 */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#ifdef _MSC_VER
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
@ -277,7 +276,6 @@ static int gm_encode(unsigned int gbdata[], const size_t length, char binary[],
|
||||
|
||||
sp = 0;
|
||||
current_mode = 0;
|
||||
last_mode = 0;
|
||||
number_pad_posn = 0;
|
||||
|
||||
if (reader) {
|
||||
|
@ -674,7 +674,6 @@ INTERNAL int gs1_verify(struct zint_symbol *symbol, const unsigned char source[]
|
||||
|
||||
/* Resolve AI data - put resulting string in 'reduced' */
|
||||
j = 0;
|
||||
last_ai = 0;
|
||||
ai_latch = 1;
|
||||
for (i = 0; i < (int) src_len; i++) {
|
||||
if ((source[i] != '[') && (source[i] != ']')) {
|
||||
|
@ -35,7 +35,6 @@
|
||||
#include "common.h"
|
||||
#include "maxicode.h"
|
||||
#include "reedsol.h"
|
||||
#include <string.h>
|
||||
|
||||
static int maxi_codeword[144];
|
||||
|
||||
@ -270,7 +269,7 @@ static int maxi_text_process(int mode, unsigned char source[], int length, int e
|
||||
if (set[i] == 2) {
|
||||
character[i] = 51;
|
||||
}
|
||||
done = 1;
|
||||
// done = 1 // As long as last branch not needed
|
||||
}
|
||||
}
|
||||
}
|
||||
|
14
backend/qr.c
14
backend/qr.c
@ -30,7 +30,6 @@
|
||||
*/
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
||||
#include <string.h>
|
||||
#ifdef _MSC_VER
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
@ -692,6 +691,9 @@ static void add_ecc(unsigned char fullstream[], const unsigned char datastream[]
|
||||
qty_short_blocks = blocks - qty_long_blocks;
|
||||
ecc_block_length = ecc_cw / blocks;
|
||||
|
||||
/* Suppress some clang-tidy clang-analyzer-core.UndefinedBinaryOperatorResult/uninitialized.Assign warnings */
|
||||
assert(short_data_block_length >= 0);
|
||||
assert(ecc_block_length * blocks == ecc_cw);
|
||||
|
||||
#ifndef _MSC_VER
|
||||
unsigned char data_block[short_data_block_length + 1];
|
||||
@ -747,8 +749,7 @@ static void add_ecc(unsigned char fullstream[], const unsigned char datastream[]
|
||||
}
|
||||
|
||||
if (i >= qty_short_blocks) {
|
||||
/* 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
|
||||
interleaved_data[(short_data_block_length * blocks) + (i - qty_short_blocks)] = data_block[short_data_block_length];
|
||||
}
|
||||
|
||||
for (j = 0; j < ecc_block_length; j++) {
|
||||
@ -988,6 +989,8 @@ static int evaluate(unsigned char *eval,const int size,const int pattern) {
|
||||
char* local = (char *) _alloca((size * size) * sizeof (char));
|
||||
#endif
|
||||
|
||||
/* Suppresses clang-tidy clang-analyzer-core.UndefinedBinaryOperatorResult warnings */
|
||||
assert(size > 0);
|
||||
|
||||
#ifdef ZINTLOG
|
||||
write_log("");
|
||||
@ -1072,10 +1075,9 @@ 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++) {
|
||||
/* NOLINT suppress clang-tidy warning: local[size * size] fully set */
|
||||
if (((local[(y * size) + x] == local[((y + 1) * size) + x]) && // NOLINT
|
||||
if (((local[(y * size) + x] == local[((y + 1) * size) + x]) &&
|
||||
(local[(y * size) + x] == local[(y * size) + (x + 1)])) &&
|
||||
(local[(y * size) + x] == local[((y + 1) * size) + (x + 1)])) { // NOLINT
|
||||
(local[(y * size) + x] == local[((y + 1) * size) + (x + 1)])) {
|
||||
result += 3;
|
||||
}
|
||||
}
|
||||
|
@ -33,17 +33,15 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#ifdef _MSC_VER
|
||||
#include <malloc.h>
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
#endif
|
||||
#include <math.h>
|
||||
#include <assert.h>
|
||||
#include "common.h"
|
||||
#include "output.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <malloc.h>
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
#include "font.h" /* Font for human readable text */
|
||||
|
||||
#define SSET "0123456789ABCDEF"
|
||||
@ -436,6 +434,7 @@ static void draw_string(char *pixbuf, unsigned char input_string[], int xposn, i
|
||||
string_left_hand = xposn - ((letter_width * string_length) / 2);
|
||||
|
||||
for (i = 0; i < string_length; i++) {
|
||||
// NOLINTNEXTLINE(clang-analyzer-core.CallAndMessage) suppress (probable) false positive about 2nd arg input_string[i] being uninitialized
|
||||
draw_letter(pixbuf, input_string[i], string_left_hand + (i * letter_width), yposn, textflags, image_width, image_height);
|
||||
}
|
||||
}
|
||||
@ -656,6 +655,7 @@ static void to_iso8859_1(const unsigned char source[], unsigned char preprocesse
|
||||
case 0xC2:
|
||||
/* UTF-8 C2xxh */
|
||||
/* Character range: C280h (latin: 80h) to C2BFh (latin: BFh) */
|
||||
assert(i + 1 < input_length);
|
||||
i++;
|
||||
preprocessed[j] = source[i];
|
||||
j++;
|
||||
@ -663,6 +663,7 @@ static void to_iso8859_1(const unsigned char source[], unsigned char preprocesse
|
||||
case 0xC3:
|
||||
/* UTF-8 C3xx */
|
||||
/* Character range: C380h (latin: C0h) to C3BFh (latin: FFh) */
|
||||
assert(i + 1 < input_length);
|
||||
i++;
|
||||
preprocessed[j] = source[i] + 64;
|
||||
j++;
|
||||
@ -954,11 +955,7 @@ static int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int
|
||||
}
|
||||
|
||||
if (!textdone) {
|
||||
#ifndef _MSC_VER
|
||||
unsigned char local_text[ustrlen(symbol->text) + 1];
|
||||
#else
|
||||
unsigned char* local_text = (unsigned char*) _alloca(ustrlen(symbol->text) + 1);
|
||||
#endif
|
||||
unsigned char local_text[sizeof(symbol->text)];
|
||||
to_iso8859_1(symbol->text, local_text);
|
||||
/* Put the human readable text at the bottom */
|
||||
textpos = 2 * (main_width / 2 + xoffset);
|
||||
|
@ -52,6 +52,7 @@
|
||||
#ifdef _MSC_VER
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#include <assert.h>
|
||||
#include "common.h"
|
||||
#include "reedsol.h"
|
||||
static int logmod; // 2**symsize - 1
|
||||
@ -72,6 +73,9 @@ static int *logt = NULL, *alog = NULL, *rspoly = NULL;
|
||||
INTERNAL void rs_init_gf(const int poly) {
|
||||
int m, b, p, v;
|
||||
|
||||
// Suppress clang-tidy clang-analyzer-core.UndefinedBinaryOperatorResult warning
|
||||
assert(poly >= 2);
|
||||
|
||||
// Find the top bit, and hence the symbol size
|
||||
for (b = 1, m = 0; b <= poly; b <<= 1)
|
||||
m++;
|
||||
|
@ -1291,6 +1291,8 @@ INTERNAL int rssexpanded(struct zint_symbol *symbol, unsigned char source[], int
|
||||
char* binary_string = (char*) _alloca(bin_len);
|
||||
#endif
|
||||
|
||||
separator_row = 0;
|
||||
|
||||
i = gs1_verify(symbol, source, src_len, reduced);
|
||||
if (i != 0) {
|
||||
return i;
|
||||
|
@ -1,5 +1,5 @@
|
||||
--- ../../../../postscriptbarcode/build/monolithic/barcode.ps 2020-07-14 14:52:24.208222925 +0100
|
||||
+++ ../tools/bwipp_dump.ps 2020-07-14 17:29:15.314238749 +0100
|
||||
--- ../../../../postscriptbarcode/build/monolithic/barcode.ps 2020-07-17 22:03:49.625837028 +0100
|
||||
+++ ../tools/bwipp_dump.ps 2020-07-17 22:10:29.222780872 +0100
|
||||
@@ -29,6 +29,8 @@
|
||||
% CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
% IN THE SOFTWARE.
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user