Fix (and test) more Clang 14 compiler warnings
-Woverlength-strings, -Wshift-negative-value, -Wsign-compare
This commit is contained in:
3
.github/workflows/build.yml
vendored
3
.github/workflows/build.yml
vendored
@@ -149,7 +149,8 @@ jobs:
|
|||||||
mkdir build
|
mkdir build
|
||||||
pushd build
|
pushd build
|
||||||
cmake -G"Unix Makefiles" -DWITH_JPEG8=1 \
|
cmake -G"Unix Makefiles" -DWITH_JPEG8=1 \
|
||||||
-DCMAKE_C_FLAGS='--std=gnu90 -Wall -Werror -Wextra -Wpedantic -pedantic-errors -Wdouble-promotion -Wformat-overflow=2 -Wformat-security -Wformat-signedness -Wformat-truncation=2 -Wformat-y2k -Wmissing-include-dirs -Wshift-overflow=2 -Wswitch-bool -Wno-unused-parameter -Wuninitialized -Wstrict-overflow=2 -Wstringop-overflow=4 -Wstringop-truncation -Wduplicated-branches -Wduplicated-cond -Wdeclaration-after-statement -Wshadow -Wunsafe-loop-optimizations -Wundef -Wcast-align -Wno-clobbered -Wjump-misses-init -Wno-sign-compare -Wlogical-op -Waggregate-return -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Wpacked -Wredundant-decls -Wnested-externs -Winline -Wno-long-long -Wdisabled-optimization -Wno-overlength-strings -fcf-protection' \
|
-DCMAKE_C_FLAGS='--std=gnu90 -Wall -Werror -Wextra -Wmost -Wnon-gcc -Wpedantic -pedantic-errors -Walloca -Wanon-enum-enum-conversion -Warray-bounds-pointer-arithmetic -Wbitfield-enum-conversion -Wc99-extensions -Wc2x-extensions -Wcast-function-type -Wcompound-token-split -Wdate-time -Wdeclaration-after-statement -Wdeprecated -Wdocumentation -Wdocumentation-pedantic -Wdouble-promotion -Wduplicate-decl-specifier -Wduplicate-enum -Wempty-init-stmt -Wexpansion-to-defined -Wextra-semi -Wformat=2 -Wformat-non-iso -Wno-format-nonliteral -Wformat-pedantic -Wformat-type-confusion -Wfour-char-constants -Wgcc-compat -Wgnu -Wheader-hygiene -Widiomatic-parentheses -Wignored-qualifiers -Wimplicit-fallthrough -Wno-implicit-int-conversion -Wincompatible-function-pointer-types -Wno-long-long -Wloop-analysis -Wmain -Wmax-tokens -Wmisleading-indentation -Wmissing-field-initializers -Wmissing-prototypes -Wmissing-variable-declarations -Wnewline-eof -Wnonportable-system-include-path -Wnullable-to-nonnull-conversion -Wold-style-cast -Wover-aligned -Wparentheses -Wpointer-arith -Wpragmas -Wpre-c2x-compat -Wredundant-parens -Wself-assign -Wshadow-all -Wshift-sign-overflow -Wno-shorten-64-to-32 -Wno-sign-conversion -Wsometimes-uninitialized -Wstatic-in-inline -Wstrict-prototypes -Wswitch-default -Wtautological-constant-in-range-compare -Wthread-safety -Wthread-safety-verbose -Wunaligned-access -Wundef -Wundef-prefix -Wundefined-func-template -Wuninitialized -Wunneeded-internal-declaration -Wunreachable-code-fallthrough -Wno-unused-command-line-argument -Wunused-member-function -Wno-unused-parameter -Wvariadic-macros -Wzero-as-null-pointer-constant -Wzero-length-array -fcf-protection' \
|
||||||
|
-DCMAKE_C_COMPILER=clang-14 \
|
||||||
..
|
..
|
||||||
export NUMCPUS=`grep -c '^processor' /proc/cpuinfo`
|
export NUMCPUS=`grep -c '^processor' /proc/cpuinfo`
|
||||||
make -j$NUMCPUS --load-average=$NUMCPUS
|
make -j$NUMCPUS --load-average=$NUMCPUS
|
||||||
|
|||||||
@@ -481,7 +481,7 @@ if(UNIX)
|
|||||||
return 1; /* right shift is signed */
|
return 1; /* right shift is signed */
|
||||||
/* see if unsigned-shift hack will fix it. */
|
/* see if unsigned-shift hack will fix it. */
|
||||||
/* we can't just test exact value since it depends on width of long... */
|
/* we can't just test exact value since it depends on width of long... */
|
||||||
res |= (~0L) << (32-4);
|
res |= 0xFFFFFFFFL << (32-4);
|
||||||
if (res == -0x7F7E80CL)
|
if (res == -0x7F7E80CL)
|
||||||
return 0; /* right shift is unsigned */
|
return 0; /* right shift is unsigned */
|
||||||
printf(\"Right shift isn't acting as I expect it to.\\\\n\");
|
printf(\"Right shift isn't acting as I expect it to.\\\\n\");
|
||||||
|
|||||||
3
cjpeg.c
3
cjpeg.c
@@ -361,7 +361,8 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
|
|||||||
if (!printed_version) {
|
if (!printed_version) {
|
||||||
fprintf(stderr, "%s version %s (build %s)\n",
|
fprintf(stderr, "%s version %s (build %s)\n",
|
||||||
PACKAGE_NAME, VERSION, BUILD);
|
PACKAGE_NAME, VERSION, BUILD);
|
||||||
fprintf(stderr, "%s\n\n", JCOPYRIGHT);
|
fprintf(stderr, JCOPYRIGHT1);
|
||||||
|
fprintf(stderr, JCOPYRIGHT2 "\n");
|
||||||
fprintf(stderr, "Emulating The Independent JPEG Group's software, version %s\n\n",
|
fprintf(stderr, "Emulating The Independent JPEG Group's software, version %s\n\n",
|
||||||
JVERSION);
|
JVERSION);
|
||||||
printed_version = TRUE;
|
printed_version = TRUE;
|
||||||
|
|||||||
3
djpeg.c
3
djpeg.c
@@ -267,7 +267,8 @@ parse_switches(j_decompress_ptr cinfo, int argc, char **argv,
|
|||||||
if (!printed_version) {
|
if (!printed_version) {
|
||||||
fprintf(stderr, "%s version %s (build %s)\n",
|
fprintf(stderr, "%s version %s (build %s)\n",
|
||||||
PACKAGE_NAME, VERSION, BUILD);
|
PACKAGE_NAME, VERSION, BUILD);
|
||||||
fprintf(stderr, "%s\n\n", JCOPYRIGHT);
|
fprintf(stderr, JCOPYRIGHT1);
|
||||||
|
fprintf(stderr, JCOPYRIGHT2 "\n");
|
||||||
fprintf(stderr, "Emulating The Independent JPEG Group's software, version %s\n\n",
|
fprintf(stderr, "Emulating The Independent JPEG Group's software, version %s\n\n",
|
||||||
JVERSION);
|
JVERSION);
|
||||||
printed_version = TRUE;
|
printed_version = TRUE;
|
||||||
|
|||||||
@@ -241,7 +241,8 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
|
|||||||
if (!printed_version) {
|
if (!printed_version) {
|
||||||
fprintf(stderr, "%s version %s (build %s)\n",
|
fprintf(stderr, "%s version %s (build %s)\n",
|
||||||
PACKAGE_NAME, VERSION, BUILD);
|
PACKAGE_NAME, VERSION, BUILD);
|
||||||
fprintf(stderr, "%s\n\n", JCOPYRIGHT);
|
fprintf(stderr, JCOPYRIGHT1);
|
||||||
|
fprintf(stderr, JCOPYRIGHT2 "\n");
|
||||||
fprintf(stderr, "Emulating The Independent JPEG Group's software, version %s\n\n",
|
fprintf(stderr, "Emulating The Independent JPEG Group's software, version %s\n\n",
|
||||||
JVERSION);
|
JVERSION);
|
||||||
printed_version = TRUE;
|
printed_version = TRUE;
|
||||||
|
|||||||
@@ -36,20 +36,21 @@
|
|||||||
* their code
|
* their code
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define JCOPYRIGHT \
|
#define JCOPYRIGHT1 \
|
||||||
"Copyright (C) 2009-2024 D. R. Commander\n" \
|
"Copyright (C) 2009-2024 D. R. Commander\n" \
|
||||||
"Copyright (C) 2015, 2020 Google, Inc.\n" \
|
"Copyright (C) 2015, 2020 Google, Inc.\n" \
|
||||||
"Copyright (C) 2019-2020 Arm Limited\n" \
|
"Copyright (C) 2019-2020 Arm Limited\n" \
|
||||||
"Copyright (C) 2015-2016, 2018 Matthieu Darbois\n" \
|
"Copyright (C) 2015-2016, 2018 Matthieu Darbois\n" \
|
||||||
"Copyright (C) 2011-2016 Siarhei Siamashka\n" \
|
"Copyright (C) 2011-2016 Siarhei Siamashka\n" \
|
||||||
"Copyright (C) 2015 Intel Corporation\n" \
|
"Copyright (C) 2015 Intel Corporation\n"
|
||||||
|
#define JCOPYRIGHT2 \
|
||||||
"Copyright (C) 2013-2014 Linaro Limited\n" \
|
"Copyright (C) 2013-2014 Linaro Limited\n" \
|
||||||
"Copyright (C) 2013-2014 MIPS Technologies, Inc.\n" \
|
"Copyright (C) 2013-2014 MIPS Technologies, Inc.\n" \
|
||||||
"Copyright (C) 2009, 2012 Pierre Ossman for Cendio AB\n" \
|
"Copyright (C) 2009, 2012 Pierre Ossman for Cendio AB\n" \
|
||||||
"Copyright (C) 2009-2011 Nokia Corporation and/or its subsidiary(-ies)\n" \
|
"Copyright (C) 2009-2011 Nokia Corporation and/or its subsidiary(-ies)\n" \
|
||||||
"Copyright (C) 1999-2006 MIYASAKA Masaru\n" \
|
"Copyright (C) 1999-2006 MIYASAKA Masaru\n" \
|
||||||
"Copyright (C) 1999 Ken Murchison\n" \
|
"Copyright (C) 1999 Ken Murchison\n" \
|
||||||
"Copyright (C) 1991-2020 Thomas G. Lane, Guido Vollbeding"
|
"Copyright (C) 1991-2020 Thomas G. Lane, Guido Vollbeding\n"
|
||||||
|
|
||||||
#define JCOPYRIGHT_SHORT \
|
#define JCOPYRIGHT_SHORT \
|
||||||
"Copyright (C) @COPYRIGHT_YEAR@ The libjpeg-turbo Project and many others"
|
"Copyright (C) @COPYRIGHT_YEAR@ The libjpeg-turbo Project and many others"
|
||||||
|
|||||||
@@ -6,7 +6,8 @@
|
|||||||
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
|
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
|
||||||
* ----------------------------------------------------------------------------
|
* ----------------------------------------------------------------------------
|
||||||
* libjpeg-turbo Modifications:
|
* libjpeg-turbo Modifications:
|
||||||
* Copyright (C)2016, 2018-2019, 2022 D. R. Commander. All Rights Reserved.
|
* Copyright (C)2016, 2018-2019, 2022, 2024 D. R. Commander.
|
||||||
|
* All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
@@ -111,7 +112,7 @@ char *MD5FileChunk(const char *filename, char *buf, off_t ofs, off_t len)
|
|||||||
n = len;
|
n = len;
|
||||||
i = 0;
|
i = 0;
|
||||||
while (n > 0) {
|
while (n > 0) {
|
||||||
if (n > sizeof(buffer))
|
if ((size_t)n > sizeof(buffer))
|
||||||
i = read(f, buffer, sizeof(buffer));
|
i = read(f, buffer, sizeof(buffer));
|
||||||
else
|
else
|
||||||
i = read(f, buffer, n);
|
i = read(f, buffer, n);
|
||||||
|
|||||||
@@ -180,7 +180,8 @@ DLLEXPORT int GET_NAME(tj3Decompress, BITS_IN_JSAMPLE)
|
|||||||
}
|
}
|
||||||
setDecompParameters(this);
|
setDecompParameters(this);
|
||||||
if (this->maxPixels &&
|
if (this->maxPixels &&
|
||||||
(unsigned long long)this->jpegWidth * this->jpegHeight > this->maxPixels)
|
(unsigned long long)this->jpegWidth * this->jpegHeight >
|
||||||
|
(unsigned long long)this->maxPixels)
|
||||||
THROW("Image is too large");
|
THROW("Image is too large");
|
||||||
this->dinfo.out_color_space = pf2cs[pixelFormat];
|
this->dinfo.out_color_space = pf2cs[pixelFormat];
|
||||||
#if BITS_IN_JSAMPLE != 16
|
#if BITS_IN_JSAMPLE != 16
|
||||||
|
|||||||
@@ -2361,7 +2361,8 @@ DLLEXPORT int tj3DecompressToYUVPlanes8(tjhandle handle,
|
|||||||
}
|
}
|
||||||
setDecompParameters(this);
|
setDecompParameters(this);
|
||||||
if (this->maxPixels &&
|
if (this->maxPixels &&
|
||||||
(unsigned long long)this->jpegWidth * this->jpegHeight > this->maxPixels)
|
(unsigned long long)this->jpegWidth * this->jpegHeight >
|
||||||
|
(unsigned long long)this->maxPixels)
|
||||||
THROW("Image is too large");
|
THROW("Image is too large");
|
||||||
if (this->subsamp == TJSAMP_UNKNOWN)
|
if (this->subsamp == TJSAMP_UNKNOWN)
|
||||||
THROW("Could not determine subsampling level of JPEG image");
|
THROW("Could not determine subsampling level of JPEG image");
|
||||||
@@ -2730,7 +2731,7 @@ DLLEXPORT int tj3Transform(tjhandle handle, const unsigned char *jpegBuf,
|
|||||||
jpeg_read_header(dinfo, TRUE);
|
jpeg_read_header(dinfo, TRUE);
|
||||||
if (this->maxPixels &&
|
if (this->maxPixels &&
|
||||||
(unsigned long long)dinfo->image_width * dinfo->image_height >
|
(unsigned long long)dinfo->image_width * dinfo->image_height >
|
||||||
this->maxPixels)
|
(unsigned long long)this->maxPixels)
|
||||||
THROW("Image is too large");
|
THROW("Image is too large");
|
||||||
this->subsamp = getSubsamp(&this->dinfo);
|
this->subsamp = getSubsamp(&this->dinfo);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user