1
0
mirror of https://git.code.sf.net/p/zint/code synced 2026-05-01 19:55:29 +00:00

general: suppress some CodeQL warnings

CODABLOCKF: tidy some comments
This commit is contained in:
gitlost
2025-02-23 19:48:55 +00:00
parent 174bbf06a8
commit c11ab5528d
6 changed files with 16 additions and 17 deletions

View File

@@ -69,7 +69,7 @@ typedef struct sCharacterSetTable {
} CharacterSetTable; } CharacterSetTable;
/* Find the possible Code-128 Character sets for a character /* Find the possible Code-128 Character sets for a character
* The result is an or of CodeA, CodeB, CodeC, CodeFNC1, CodeFNC4 depending on the * The result is an OR of CodeA, CodeB, CodeC, CodeFNC1, CodeFNC4 depending on the
* possible Code 128 character sets. * possible Code 128 character sets.
*/ */
static int GetPossibleCharacterSet(unsigned char C) { static int GetPossibleCharacterSet(unsigned char C) {
@@ -87,13 +87,11 @@ static int GetPossibleCharacterSet(unsigned char C) {
} }
/* Create a Table with the following information for each Data character: /* Create a Table with the following information for each Data character:
* int CharacterSet is an or of CodeA, CodeB, CodeC, CodeFNC1, CodeFNC4, * int CharacterSet is an OR of CodeA, CodeB, CodeC, CodeFNC1, CodeFNC4,
* depending on which character set is applicable. * depending on which character set is applicable.
* (Result of GetPossibleCharacterSet) * (Result of GetPossibleCharacterSet)
* int AFollowing,BFollowing The number of source characters you still may encode * int AFollowing, BFollowing The number of source characters you still may encode in this character set.
* in this character set. * int CFollowing The number of characters encodable in CodeC if we start here.
* int CFollowing The number of characters encodable in CodeC if we
* start here.
*/ */
static void CreateCharacterSetTable(CharacterSetTable T[], unsigned char *data, const int dataLength) { static void CreateCharacterSetTable(CharacterSetTable T[], unsigned char *data, const int dataLength) {
int charCur; int charCur;
@@ -260,6 +258,7 @@ static int Columns2Rows(struct zint_symbol *symbol, CharacterSetTable *T, const
if (isFNC4) { /* So skip FNC4 and shift value instead */ if (isFNC4) { /* So skip FNC4 and shift value instead */
--emptyColumns; --emptyColumns;
++charCur; ++charCur;
assert(charCur < dataLength); /* FNC4s always followed by char */
} }
pSet[charCur] |= CShift; pSet[charCur] |= CShift;
} else { } else {
@@ -292,6 +291,7 @@ static int Columns2Rows(struct zint_symbol *symbol, CharacterSetTable *T, const
if (isFNC4) { /* So skip FNC4 and shift value instead */ if (isFNC4) { /* So skip FNC4 and shift value instead */
--emptyColumns; --emptyColumns;
++charCur; ++charCur;
assert(charCur < dataLength); /* FNC4s always followed by char */
} }
pSet[charCur] |= CShift; pSet[charCur] |= CShift;
} else { } else {
@@ -684,7 +684,7 @@ INTERNAL int codablockf(struct zint_symbol *symbol, unsigned char source[], int
/* >>> Build C128 code numbers */ /* >>> Build C128 code numbers */
/* The C128 column count contains Start (2CW), Row ID, Checksum, Stop */ /* The C128 column count contains Start (2CW), Row ID, Checksum, Stop */
pOutput = (unsigned char *) z_alloca(columns * rows); pOutput = (unsigned char *) z_alloca((size_t) columns * (size_t) rows);
pOutPos = pOutput; pOutPos = pOutput;
charCur = 0; charCur = 0;
/* >> Loop over rows */ /* >> Loop over rows */
@@ -780,7 +780,7 @@ INTERNAL int codablockf(struct zint_symbol *symbol, unsigned char source[], int
--emptyColumns; --emptyColumns;
} }
/* >> End Criteria */ /* >> End Criteria */
if ((pSet[charCur] & CFill) || (pSet[charCur] & CEnd)) { if (charCur < dataLength && ((pSet[charCur] & CFill) || (pSet[charCur] & CEnd))) {
/* Fill line but leave space for checks in last line */ /* Fill line but leave space for checks in last line */
if (rowCur == rows - 1) { if (rowCur == rows - 1) {
emptyColumns -= 2; emptyColumns -= 2;

View File

@@ -1904,7 +1904,7 @@ static int dm_ecc200(struct zint_symbol *symbol, struct zint_seg segs[], const i
const int NC = W - 2 * (W / FW); const int NC = W - 2 * (W / FW);
const int NR = H - 2 * (H / FH); const int NR = H - 2 * (H / FH);
int x, y, *places; int x, y, *places;
if (!(places = (int *) calloc(NC * NR, sizeof(int)))) { if (!(places = (int *) calloc((size_t) NC * (size_t) NR, sizeof(int)))) {
return errtxt(ZINT_ERROR_MEMORY, symbol, 718, "Insufficient memory for placement array"); return errtxt(ZINT_ERROR_MEMORY, symbol, 718, "Insufficient memory for placement array");
} }
dm_placement(places, NR, NC); dm_placement(places, NR, NC);

View File

@@ -138,7 +138,8 @@ static int dx_parse_code(struct zint_symbol *symbol, const unsigned char *source
int dx_extract; int dx_extract;
/* DX format is either 4 digits (DX Extract, eg: 1271) or 6 digits (DX Full, eg: 012710) */ /* DX format is either 4 digits (DX Extract, eg: 1271) or 6 digits (DX Full, eg: 012710) */
if (debug_print) printf("No \"-\" separator, computing from DX Extract (4 digits) or DX Full (6 digits)\n"); if (debug_print) printf("No \"-\" separator, computing from DX Extract (4 digits) or DX Full (6 digits)\n");
if (dx_length == 5 || dx_length > 6) { assert(dx_length <= 6); /* I.e. DX_MAX_DX_INFO_LENGTH, guaranteed above */
if (dx_length == 5) {
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 980, return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 980,
"DX number \"%s\" is incorrect; expected 4 digits (DX extract) or 6 digits (DX full)", dx_info); "DX number \"%s\" is incorrect; expected 4 digits (DX extract) or 6 digits (DX full)", dx_info);
} }
@@ -154,7 +155,7 @@ static int dx_parse_code(struct zint_symbol *symbol, const unsigned char *source
} }
/* Compute the DX parts 1 and 2 from the DX extract */ /* Compute the DX parts 1 and 2 from the DX extract */
dx_extract = to_int((const unsigned char *) dx_info, dx_length); dx_extract = to_int((const unsigned char *) dx_info, dx_length);
assert(dx_extract != -1); assert(dx_extract != -1); /* All digits (no hyphen) & length 6 max - can't fail */
if (dx_extract < 16 || dx_extract > 2047) { if (dx_extract < 16 || dx_extract > 2047) {
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 981, "DX extract \"%d\" out of range (16 to 2047)", return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 981, "DX extract \"%d\" out of range (16 to 2047)",
dx_extract); dx_extract);

View File

@@ -875,8 +875,6 @@ static void gm_add_ecc(const char binary[], const int data_posn, const int layer
} }
data_size = block_size - ecc_size; data_size = block_size - ecc_size;
/* printf("block %d/%d: data %d / ecc %d\n", i + 1, (b1 + b2), data_size, ecc_size);*/
for (j = 0; j < data_size; j++) { for (j = 0; j < data_size; j++) {
data_block[j] = data[wp]; data_block[j] = data[wp];
wp++; wp++;

View File

@@ -1531,7 +1531,7 @@ int ZBarcode_Encode_File(struct zint_symbol *symbol, const char *filename) {
} }
/* Allocate memory */ /* Allocate memory */
buffer = (unsigned char *) malloc(fileLen); buffer = (unsigned char *) malloc((size_t) fileLen);
if (!buffer) { if (!buffer) {
if (file_opened) { if (file_opened) {
(void) fclose(file); (void) fclose(file);

View File

@@ -1141,7 +1141,7 @@ INTERNAL int ultra(struct zint_symbol *symbol, struct zint_seg segs[], const int
total_width = columns + 6; total_width = columns + 6;
/* Build symbol */ /* Build symbol */
pattern = (char *) z_alloca(total_height * total_width); pattern = (char *) z_alloca((size_t) total_height * (size_t) total_width);
for (i = 0; i < (total_height * total_width); i++) { for (i = 0; i < (total_height * total_width); i++) {
pattern[i] = 'W'; pattern[i] = 'W';