Change height and row_height array to floats: VC6, CodeQL fixes

This commit is contained in:
gitlost 2021-06-20 00:05:45 +01:00
parent c693482aa1
commit e5115bad07
8 changed files with 15 additions and 17 deletions

View File

@ -640,7 +640,7 @@ INTERNAL int codablock(struct zint_symbol *symbol, unsigned char source[], int l
int emptyColumns;
char dest[1000];
int r, c;
float min_row_height;
float min_row_height = 0.0f;
#ifdef _MSC_VER
CharacterSetTable *T;
unsigned char *data;
@ -997,8 +997,7 @@ INTERNAL int codablock(struct zint_symbol *symbol, unsigned char source[], int l
error_number = set_height(symbol, min_row_height, (min_row_height > 10.0f ? min_row_height : 10.0f) * rows, 0.0f,
0 /*no_errtxt*/);
#else
(void)min_row_height;
(void) set_height(symbol, 0.0f, 10.0f * rows, 0.0f, 1 /*no_errtxt*/);
(void) set_height(symbol, min_row_height, 10.0f * rows, 0.0f, 1 /*no_errtxt*/);
#endif
symbol->output_options |= BARCODE_BIND;

View File

@ -861,7 +861,7 @@ static int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigne
db_p = bin_append_posn(1, 2, decimal_binary, db_p);
}
(void)decimal_binary_transfer(decimal_binary, db_p, target, &tp);
(void) decimal_binary_transfer(decimal_binary, db_p, target, &tp);
}
current_mode = C1_ASCII;

View File

@ -120,7 +120,7 @@ INTERNAL int code16k(struct zint_symbol *symbol, unsigned char source[], int len
int input_length;
int gs1, c_count;
int separator;
float min_row_height;
float min_row_height = 0.0f;
/* Suppresses clang-analyzer-core.UndefinedBinaryOperatorResult warning on fset which is fully set */
assert(length > 0);
@ -500,8 +500,8 @@ INTERNAL int code16k(struct zint_symbol *symbol, unsigned char source[], int len
error_number = set_height(symbol, min_row_height, (min_row_height > 10.0f ? min_row_height : 10.0f) * rows, 0.0f,
0 /*no_errtxt*/);
#else
(void)min_row_height; (void)separator;
(void) set_height(symbol, 0.0f, 10.0f * rows, 0.0f, 1 /*no_errtxt*/);
(void)&separator;
(void) set_height(symbol, min_row_height, 10.0f * rows, 0.0f, 1 /*no_errtxt*/);
#endif
symbol->output_options |= BARCODE_BIND;

View File

@ -50,7 +50,7 @@ INTERNAL int code_49(struct zint_symbol *symbol, unsigned char source[], int len
int gs1;
int h, len;
int separator;
float min_row_height;
float min_row_height = 0.0f;
int error_number = 0;
if (length > 81) {
@ -358,8 +358,8 @@ INTERNAL int code_49(struct zint_symbol *symbol, unsigned char source[], int len
error_number = set_height(symbol, min_row_height, (min_row_height > 10.0f ? min_row_height : 10.0f) * rows, 0.0f,
0 /*no_errtxt*/);
#else
(void)min_row_height; (void)separator;
(void) set_height(symbol, 0.0f, 10.0f * rows, 0.0f, 1 /*no_errtxt*/);
(void)&separator;
(void) set_height(symbol, min_row_height, 10.0f * rows, 0.0f, 1 /*no_errtxt*/);
#endif
symbol->output_options |= BARCODE_BIND;

View File

@ -64,6 +64,9 @@
# define ceilf (float) ceil
# define floorf (float) floor
# define roundf(arg) ((float) floor((arg) + 0.5f))
# if _MSC_VER == 1200 /* VC6 */
# define round(arg) floor((arg) + 0.5f)
# endif
# endif
# pragma warning(disable: 4244) /* conversion from int to float */
# if _MSC_VER >= 1900 /* MSVC 2015 */

View File

@ -1243,7 +1243,7 @@ int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int
if (error_number == 0) {
error_number = warn_number;
}
(void)error_tag(symbol->errtxt, error_number);
(void) error_tag(symbol->errtxt, error_number);
if (error_number < ZINT_ERROR) {
if (symbol->height < 0.5f) { /* Absolute minimum */

View File

@ -555,7 +555,7 @@ INTERNAL float output_large_bar_height(struct zint_symbol *symbol, int si) {
symbol->height = large_bar_height * zero_count + fixed_height;
}
if (si && large_bar_height * si != (int) (large_bar_height * si)) {
large_bar_height = (float) (round(large_bar_height * si) / si);
large_bar_height = roundf(large_bar_height * si) / si;
symbol->height = large_bar_height * zero_count + fixed_height;
}
/* Note should never happen that have both zero_count and round_rows */
@ -565,7 +565,7 @@ INTERNAL float output_large_bar_height(struct zint_symbol *symbol, int si) {
fixed_height = 0.0f;
for (i = 0; i < symbol->rows; i++) {
if (symbol->row_height[i] * si != (int) (symbol->row_height[i] * si)) {
symbol->row_height[i] = (float) (round(symbol->row_height[i] * si) / si);
symbol->row_height[i] = roundf(symbol->row_height[i] * si) / si;
}
fixed_height += symbol->row_height[i];
}

View File

@ -35,10 +35,6 @@
#ifdef _MSC_VER
#include <malloc.h>
/* For Visual C++ 6 suppress conversion from int to float warning */
#if _MSC_VER == 1200
#pragma warning(disable: 4244)
#endif
#endif
#include "common.h"