diff --git a/backend/common.c b/backend/common.c index ac91b112..eac8fdb2 100644 --- a/backend/common.c +++ b/backend/common.c @@ -487,20 +487,30 @@ INTERNAL int set_height(struct zint_symbol *symbol, const float min_row_height, if (row_height < 0.5f) { /* Absolute minimum */ row_height = 0.5f; } - if (min_row_height && stripf(row_height) < stripf(min_row_height)) { - error_number = ZINT_WARN_NONCOMPLIANT; - if (!no_errtxt) { - strcpy(symbol->errtxt, "247: Height not compliant with standards"); + if (min_row_height) { + /* This seems necessary to get gcc 12.2.1 to work consistently for static 32-bit builds */ + volatile const float row_height_strip = stripf(row_height); + volatile const float min_row_height_strip = stripf(min_row_height); + if (row_height_strip < min_row_height_strip) { + error_number = ZINT_WARN_NONCOMPLIANT; + if (!no_errtxt) { + strcpy(symbol->errtxt, "247: Height not compliant with standards"); + } } } symbol->height = stripf(row_height * zero_count + fixed_height); } else { symbol->height = stripf(fixed_height); /* Ignore any given height */ } - if (max_height && stripf(symbol->height) > stripf(max_height)) { - error_number = ZINT_WARN_NONCOMPLIANT; - if (!no_errtxt) { - strcpy(symbol->errtxt, "248: Height not compliant with standards"); + if (max_height) { + /* See above */ + volatile const float symbol_height_strip = stripf(symbol->height); + volatile const float max_height_strip = stripf(max_height); + if (symbol_height_strip > max_height_strip) { + error_number = ZINT_WARN_NONCOMPLIANT; + if (!no_errtxt) { + strcpy(symbol->errtxt, "248: Height not compliant with standards"); + } } } diff --git a/backend/tests/test_library.c b/backend/tests/test_library.c index 1aded07c..d3486ec8 100644 --- a/backend/tests/test_library.c +++ b/backend/tests/test_library.c @@ -837,6 +837,10 @@ static void test_encode_file_unreadable(void) { #ifdef _WIN32 testSkip("Test not implemented on Windows"); #else + if (getuid() == 0) { + testSkip("Test not available as root"); + return; + } symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); diff --git a/frontend/tests/test_args.c b/frontend/tests/test_args.c index 7acee653..232c7c3a 100644 --- a/frontend/tests/test_args.c +++ b/frontend/tests/test_args.c @@ -803,7 +803,7 @@ static void test_checks(int index, int debug) { char cmd[4096]; char buf[4096]; - char *outfilename = "out.gif"; + const char *outfilename = "out.gif"; testStart("test_checks"); @@ -1064,7 +1064,7 @@ static void test_barcode_symbology(int index, int debug) { char cmd[4096]; char buf[8192]; - char *outfilename = "out.gif"; + const char *outfilename = "out.gif"; testStart("test_barcode_symbology"); @@ -1158,6 +1158,11 @@ static void test_other_opts(int index, int debug) { char cmd[4096]; char buf[8192]; +#ifdef NO_PNG + const char *outfilename = "out.gif"; +#else + const char *outfilename = "out.png"; +#endif testStart("test_other_opts"); @@ -1183,6 +1188,9 @@ static void test_other_opts(int index, int debug) { assert_nonnull(strstr(buf, data[i].expected), "i:%d strstr buf (%s) != expected (%s) (%s)\n", i, buf, data[i].expected, cmd); } else { assert_zero(strcmp(buf, data[i].expected), "i:%d strcmp buf (%s) != expected (%s) (%s)\n", i, buf, data[i].expected, cmd); + if (strstr(data[i].expected, "Error") == NULL) { + assert_zero(remove(outfilename), "i:%d remove(%s) != 0 (%d: %s)\n", i, outfilename, errno, strerror(errno)); + } } } @@ -1214,6 +1222,11 @@ static void test_exit_status(int index, int debug) { char cmd[4096]; char buf[8192]; +#ifdef NO_PNG + const char *outfilename = "out.gif"; +#else + const char *outfilename = "out.png"; +#endif testStart("test_exit_status"); @@ -1237,6 +1250,9 @@ static void test_exit_status(int index, int debug) { assert_nonnull(exec(cmd, buf, sizeof(buf) - 1, debug, i, &exit_status), "i:%d exec(%s) NULL\n", i, cmd); assert_equal(exit_status, data[i].expected, "i:%d exit_status %d != expected (%d) (%s), (cmd: %s)\n", i, exit_status, data[i].expected, buf, cmd); + if (data[i].expected < ZINT_ERROR) { + assert_zero(remove(outfilename), "i:%d remove(%s) != 0 (%d: %s)\n", i, outfilename, errno, strerror(errno)); + } } testFinish();