summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2021-02-08 14:53:25 +0000
committerEven Rouault <even.rouault@spatialys.com>2021-02-08 14:53:25 +0000
commite79670aa50fca7e7bb98b050b06dd86c7cada6a2 (patch)
tree6818f51bd09a0161ffb3dd64789184da2e8f1c04
parent913d8f4cadd07da2abd48926749c0b95c38fd1ca (diff)
parent91f9730fec238cfd4fb8489ed553da0c6cec2522 (diff)
downloadlibtiff-git-e79670aa50fca7e7bb98b050b06dd86c7cada6a2.tar.gz
Merge branch 'warning-fixes' into 'master'
Warning fixes See merge request libtiff/libtiff!222
-rw-r--r--.appveyor.yml5
-rw-r--r--build/gitlab-ci5
-rw-r--r--libtiff/tif_fax3.c54
-rw-r--r--libtiff/tif_zstd.c1
-rw-r--r--test/CMakeLists.txt3
-rw-r--r--test/custom_dir_EXIF_231.c225
-rw-r--r--tools/tiff2bw.c3
-rw-r--r--tools/tiff2pdf.c2
-rw-r--r--tools/tiff2ps.c40
-rw-r--r--tools/tiff2rgba.c2
-rw-r--r--tools/tiffcmp.c2
-rw-r--r--tools/tiffcp.c2
-rw-r--r--tools/tiffdither.c3
-rw-r--r--tools/tiffinfo.c4
-rw-r--r--tools/tiffmedian.c2
15 files changed, 187 insertions, 166 deletions
diff --git a/.appveyor.yml b/.appveyor.yml
index 4b5e53f3..9c4adab1 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -64,7 +64,8 @@ before_build:
- 'if %compiler%==cygwin-cmake cygpath --version || echo cygpath not found'
- 'if %compiler%==cygwin-cmake cmake --version || echo CMake not found'
- set "AV_CMAKE_ARGS=-DBUILD_SHARED_LIBS:BOOL=%shared%"
- - set "AV_CMAKE_ARGS=-DBUILD_SHARED_LIBS:BOOL=%shared%"
+ - 'if %compiler%==cygwin-cmake set "AV_CMAKE_ARGS=%AV_CMAKE_ARGS% -Dfatal-warnings=ON"'
+ - 'if %compiler%==mingw32-cmake set "AV_CMAKE_ARGS=%AV_CMAKE_ARGS% -Dfatal-warnings=ON"'
- set "AV_TIFF_CMAKE_SOURCE=%AV_TIFF_SOURCE%"
- set "AV_TIFF_CMAKE_INSTALL=%AV_TIFF_INSTALL%"
- 'if %compiler%==cygwin-cmake set "AV_TIFF_CMAKE_SOURCE=%AV_TIFF_CYG_SOURCE%'
@@ -73,7 +74,7 @@ before_build:
- 'if %compiler%==vc14-nmake call "%VS140COMNTOOLS%..\..\VC\vcvarsall.bat" %platform%'
- mkdir %AV_TIFF_BUILD%
- cd %AV_TIFF_BUILD%
- - if NOT %compiler%==vc14-nmake echo Running cmake -G "%generator%" -DCMAKE_INSTALL_PREFIX=%AV_TIFF_CMAKE_INSTALL% -DCMAKE_BUILD_TYPE=%configuration% %AV_TIFF_CMAKE_SOURCE%
+ - if NOT %compiler%==vc14-nmake echo Running cmake -G "%generator%" -DCMAKE_INSTALL_PREFIX=%AV_TIFF_CMAKE_INSTALL% -DCMAKE_BUILD_TYPE=%configuration% %AV_CMAKE_ARGS% %AV_TIFF_CMAKE_SOURCE%
- 'if %compiler%==cygwin-cmake bash -c "cmake -G \"%generator%\" -DCMAKE_INSTALL_PREFIX:PATH=%AV_TIFF_CMAKE_INSTALL% -DCMAKE_BUILD_TYPE=%configuration% %AV_CMAKE_ARGS% %AV_TIFF_CMAKE_SOURCE%"'
- 'if %compiler%==mingw-cmake cmake -G "%generator%" -DCMAKE_INSTALL_PREFIX:PATH=%AV_TIFF_CMAKE_INSTALL% -DCMAKE_BUILD_TYPE=%configuration% %AV_CMAKE_ARGS% %AV_TIFF_CMAKE_SOURCE%'
- 'if %compiler%==vc14-cmake cmake -G "%generator%" -A %arch% -DCMAKE_INSTALL_PREFIX:PATH=%AV_TIFF_CMAKE_INSTALL% -DCMAKE_BUILD_TYPE=%configuration% %AV_CMAKE_ARGS% %AV_TIFF_CMAKE_SOURCE%'
diff --git a/build/gitlab-ci b/build/gitlab-ci
index 7b5d2498..1280f2c4 100644
--- a/build/gitlab-ci
+++ b/build/gitlab-ci
@@ -29,8 +29,9 @@ cmake_build()
fi
mkdir cmake-build
cd cmake-build
- echo "Running cmake -G "$1" -DCMAKE_BUILD_TYPE="$2" -DCMAKE_INSTALL_PREFIX=../autoconf-install ${opts} .."
- cmake -G "$1" -DCMAKE_BUILD_TYPE="$2" -DCMAKE_INSTALL_PREFIX=../autoconf-install ${opts} ..
+ opts="-Dfatal-warnings=ON"
+ echo "Running cmake -G "$1" -DCMAKE_BUILD_TYPE="$2" -DCMAKE_INSTALL_PREFIX=../cmake-install ${opts} .."
+ cmake -G "$1" -DCMAKE_BUILD_TYPE="$2" -DCMAKE_INSTALL_PREFIX=../cmake-install ${opts} ..
cmake --build .
cmake --build . --target install
ctest -V
diff --git a/libtiff/tif_fax3.c b/libtiff/tif_fax3.c
index a61362af..e05eb6aa 100644
--- a/libtiff/tif_fax3.c
+++ b/libtiff/tif_fax3.c
@@ -327,47 +327,19 @@ Fax3Decode2D(TIFF* tif, uint8_t* buf, tmsize_t occ, uint16_t s)
}
#undef SWAP
-/*
- * The ZERO & FILL macros must handle spans < 2*sizeof(int64_t) bytes.
- */
-# define FILL(n, cp) \
- switch (n) { \
- case 15:(cp)[14] = 0xff; /*-fallthrough*/ \
- case 14:(cp)[13] = 0xff; /*-fallthrough*/ \
- case 13:(cp)[12] = 0xff; /*-fallthrough*/ \
- case 12:(cp)[11] = 0xff; /*-fallthrough*/ \
- case 11:(cp)[10] = 0xff; /*-fallthrough*/ \
- case 10: (cp)[9] = 0xff; /*-fallthrough*/ \
- case 9: (cp)[8] = 0xff; /*-fallthrough*/ \
- case 8: (cp)[7] = 0xff; /*-fallthrough*/ \
- case 7: (cp)[6] = 0xff; /*-fallthrough*/ \
- case 6: (cp)[5] = 0xff; /*-fallthrough*/ \
- case 5: (cp)[4] = 0xff; /*-fallthrough*/ \
- case 4: (cp)[3] = 0xff; /*-fallthrough*/ \
- case 3: (cp)[2] = 0xff; /*-fallthrough*/ \
- case 2: (cp)[1] = 0xff; /*-fallthrough*/ \
- case 1: (cp)[0] = 0xff; (cp) += (n); /*-fallthrough*/ \
- case 0: ; \
- }
-# define ZERO(n, cp) \
- switch (n) { \
- case 15:(cp)[14] = 0; /*-fallthrough*/ \
- case 14:(cp)[13] = 0; /*-fallthrough*/ \
- case 13:(cp)[12] = 0; /*-fallthrough*/ \
- case 12:(cp)[11] = 0; /*-fallthrough*/ \
- case 11:(cp)[10] = 0; /*-fallthrough*/ \
- case 10: (cp)[9] = 0; /*-fallthrough*/ \
- case 9: (cp)[8] = 0; /*-fallthrough*/ \
- case 8: (cp)[7] = 0; /*-fallthrough*/ \
- case 7: (cp)[6] = 0; /*-fallthrough*/ \
- case 6: (cp)[5] = 0; /*-fallthrough*/ \
- case 5: (cp)[4] = 0; /*-fallthrough*/ \
- case 4: (cp)[3] = 0; /*-fallthrough*/ \
- case 3: (cp)[2] = 0; /*-fallthrough*/ \
- case 2: (cp)[1] = 0; /*-fallthrough*/ \
- case 1: (cp)[0] = 0; (cp) += (n); /*-fallthrough*/ \
- case 0: ; \
- }
+# define FILL(n, cp) \
+ for (int32_t ifill = 0; ifill < (n); ++ifill) \
+ { \
+ (cp)[ifill] = 0xff; \
+ } \
+ (cp) += (n);
+
+# define ZERO(n, cp) \
+ for (int32_t izero = 0; izero < (n); ++izero) \
+ { \
+ (cp)[izero] = 0; \
+ } \
+ (cp) += (n);
/*
* Bit-fill a row according to the white/black
diff --git a/libtiff/tif_zstd.c b/libtiff/tif_zstd.c
index 3411d3a4..14ac0811 100644
--- a/libtiff/tif_zstd.c
+++ b/libtiff/tif_zstd.c
@@ -375,6 +375,7 @@ TIFFInitZSTD(TIFF* tif, int scheme)
static const char module[] = "TIFFInitZSTD";
ZSTDState* sp;
+ (void) scheme;
assert( scheme == COMPRESSION_ZSTD );
/*
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index d5c31f24..5fde751f 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -187,8 +187,7 @@ target_link_libraries(rewrite tiff port)
if(JPEG_SUPPORT)
add_executable(raw_decode raw_decode.c)
- target_include_directories(raw_decode PRIVATE ${JPEG_INCLUDE_DIR})
- target_link_libraries(raw_decode tiff port)
+ target_link_libraries(raw_decode tiff port JPEG::JPEG)
endif()
add_executable(custom_dir custom_dir.c)
diff --git a/test/custom_dir_EXIF_231.c b/test/custom_dir_EXIF_231.c
index a0d78fa1..892c442b 100644
--- a/test/custom_dir_EXIF_231.c
+++ b/test/custom_dir_EXIF_231.c
@@ -66,6 +66,7 @@
#include "tif_config.h"
#include <stdio.h>
+#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <errno.h>
@@ -596,6 +597,7 @@ write_test_tiff(TIFF *tif, const char *filenameRead)
nTags = tFieldArray->count;
for (i=0; i<nTags; i++) {
+ bool deferredSetField = false;
tTag = tFieldArray->fields[i].field_tag;
tType = tFieldArray->fields[i].field_type; /* e.g. TIFF_RATIONAL */
tWriteCount = tFieldArray->fields[i].field_writecount;
@@ -689,46 +691,55 @@ write_test_tiff(TIFF *tif, const char *filenameRead)
case TIFF_SETGET_C32_SINT8:
/* For arrays, distinguishing between float or double is essential, even for writing */
pVoid = &auxCharArrayW[i];
+ deferredSetField = true;
+ break;
case TIFF_SETGET_C0_UINT16:
case TIFF_SETGET_C0_SINT16:
case TIFF_SETGET_C16_UINT16:
case TIFF_SETGET_C16_SINT16:
case TIFF_SETGET_C32_UINT16:
case TIFF_SETGET_C32_SINT16:
- if (pVoid == NULL) pVoid = &auxShortArrayW[i];
+ pVoid = &auxShortArrayW[i];
+ deferredSetField = true;
+ break;
case TIFF_SETGET_C0_UINT32:
case TIFF_SETGET_C0_SINT32:
case TIFF_SETGET_C16_UINT32:
case TIFF_SETGET_C16_SINT32:
case TIFF_SETGET_C32_UINT32:
case TIFF_SETGET_C32_SINT32:
- if (pVoid == NULL) pVoid = &auxLongArrayW[i];
- /* _Cxx_ just defines the size of the count parameter for the array as C0=char, C16=short or C32=long */
- /*-- Check, if it is a single parameter, a fixed array or a variable array */
- if (tWriteCount == 1) {
- fprintf (stderr, "WriteCount for .set_field_type %d should be -1 or greater than 1! %s\n", tSetFieldType, tFieldArray->fields[i].field_name);
+ pVoid = &auxLongArrayW[i];
+ deferredSetField = true;
+ break;
+ default:
+ fprintf (stderr, "SetFieldType %d not defined within writing switch for %s.\n", tSetFieldType, tFieldName);
+ }; /*-- switch() --*/
+
+ if (deferredSetField) {
+ /* _Cxx_ just defines the size of the count parameter for the array as C0=char, C16=short or C32=long */
+ /*-- Check, if it is a single parameter, a fixed array or a variable array */
+ if (tWriteCount == 1) {
+ fprintf(stderr, "WriteCount for .set_field_type %d should be -1 or greater than 1! %s\n",
+ tSetFieldType, tFieldArray->fields[i].field_name);
+ } else {
+ /*-- Either fix or variable array --*/
+ /* Now decide between fixed or variable array */
+ if (tWriteCount > 1) {
+ /* fixed array with needed arraysize defined in .field_writecount */
+ if (!TIFFSetField(tif, tTag, pVoid)) {
+ fprintf(stderr, "Can't write %s\n", tFieldArray->fields[i].field_name);
+ goto failure;
+ }
} else {
- /*-- Either fix or variable array --*/
- /* Now decide between fixed or variable array */
- if (tWriteCount > 1) {
- /* fixed array with needed arraysize defined in .field_writecount */
- if (!TIFFSetField( tif, tTag, pVoid)) {
- fprintf (stderr, "Can't write %s\n", tFieldArray->fields[i].field_name);
- goto failure;
- }
- } else {
- /* special treatment of variable array */
- /* for test, use always arraysize of VARIABLE_ARRAY_SIZE */
- if (!TIFFSetField( tif, tTag, VARIABLE_ARRAY_SIZE, pVoid)) {
- fprintf (stderr, "Can't write %s\n", tFieldArray->fields[i].field_name);
- goto failure;
- }
+ /* special treatment of variable array */
+ /* for test, use always arraysize of VARIABLE_ARRAY_SIZE */
+ if (!TIFFSetField(tif, tTag, VARIABLE_ARRAY_SIZE, pVoid)) {
+ fprintf(stderr, "Can't write %s\n", tFieldArray->fields[i].field_name);
+ goto failure;
}
}
- break;
- default:
- fprintf (stderr, "SetFieldType %d not defined within writing switch for %s.\n", tSetFieldType, tFieldName);
- }; /*-- switch() --*/
+ }
+ }
} /*-- for() --*/
/*================= EXIF: END Writing arbitrary data to the EXIF fields END END END ==============*/
#endif /*-- WRITE_ALL_EXIF_TAGS --*/
@@ -1077,6 +1088,7 @@ write_test_tiff(TIFF *tif, const char *filenameRead)
}
for (i=0; i<nTags; i++) {
+ bool deferredSetField = false;
tTag = tFieldArray->fields[i].field_tag;
tType = tFieldArray->fields[i].field_type; /* e.g. TIFF_RATIONAL */
tWriteCount = tFieldArray->fields[i].field_writecount;
@@ -1095,7 +1107,8 @@ write_test_tiff(TIFF *tif, const char *filenameRead)
break;
}
/* Save string from temporary buffer and compare with written string. */
- strncpy(auxCharArray, pAscii, sizeof(auxCharArray));
+ strncpy(auxCharArray, pAscii, sizeof(auxCharArray) - 1u);
+ auxCharArray[sizeof(auxCharArray) - 1u] = '\0';
if (tWriteCount > 0) auxLong = tWriteCount-1; else auxLong = (long)strlen(auxCharArray);
retCode2 = strncmp(auxCharArray, auxTextArrayW[i], auxLong);
if (retCode2 != 0) {
@@ -1276,99 +1289,113 @@ write_test_tiff(TIFF *tif, const char *filenameRead)
case TIFF_SETGET_C32_SINT8:
/* For arrays, distinguishing between float or double is essential, even for writing */
pVoid = &auxCharArrayW[i];
- case TIFF_SETGET_C0_UINT16:
+ deferredSetField = true;
+ break;
+ case TIFF_SETGET_C0_UINT16:
case TIFF_SETGET_C0_SINT16:
case TIFF_SETGET_C16_UINT16:
case TIFF_SETGET_C16_SINT16:
case TIFF_SETGET_C32_UINT16:
case TIFF_SETGET_C32_SINT16:
- if (pVoid == NULL) pVoid = &auxShortArrayW[i];
+ pVoid = &auxShortArrayW[i];
+ deferredSetField = true;
+break;
case TIFF_SETGET_C0_UINT32:
case TIFF_SETGET_C0_SINT32:
case TIFF_SETGET_C16_UINT32:
case TIFF_SETGET_C16_SINT32:
case TIFF_SETGET_C32_UINT32:
case TIFF_SETGET_C32_SINT32:
- if (pVoid == NULL) pVoid = &auxLongArrayW[i];
- /* _Cxx_ just defines the size of the count parameter for the array as C0=char, C16=short or C32=long */
- /*-- Check, if it is a single parameter, a fixed array or a variable array */
- if (tWriteCount == 1) {
- fprintf (stderr, "WriteCount for .set_field_type %d should be -1 or greater than 1! %s\n", tSetFieldType, tFieldArray->fields[i].field_name);
+ pVoid = &auxLongArrayW[i];
+ deferredSetField = true;
+ break;
+ default:
+ fprintf (stderr, "SetFieldType %d not defined within writing switch for %s.\n", tSetFieldType, tFieldName);
+ GOTOFAILURE
+ }; /*-- switch() --*/
+
+ if(deferredSetField) {
+ /* _Cxx_ just defines the size of the count parameter for the array as C0=char, C16=short or C32=long */
+ /*-- Check, if it is a single parameter, a fixed array or a variable array */
+ if (tWriteCount == 1) {
+ fprintf(stderr, "WriteCount for .set_field_type %d should be -1 or greater than 1! %s\n",
+ tSetFieldType, tFieldArray->fields[i].field_name);
+ } else {
+ /*-- Either fix or variable array --*/
+ /* Now decide between fixed or variable array */
+ if (tWriteCount > 1) {
+ /* fixed array with needed arraysize defined in .field_writecount */
+ if (!TIFFGetField(tif, tTag, &pVoidArray)) {
+ fprintf(stderr, "Can't read %s\n", tFieldArray->fields[i].field_name);
+ GOTOFAILURE_ALL_EXIF
+ break;
+ }
+ /* set tWriteCount to number of read samples for next steps */
+ auxLong = tWriteCount;
} else {
- /*-- Either fix or variable array --*/
- /* Now decide between fixed or variable array */
- if (tWriteCount > 1) {
- /* fixed array with needed arraysize defined in .field_writecount */
- if (!TIFFGetField( tif, tTag, &pVoidArray)) {
- fprintf (stderr, "Can't read %s\n", tFieldArray->fields[i].field_name);
- GOTOFAILURE_ALL_EXIF
- break;
- }
- /* set tWriteCount to number of read samples for next steps */
- auxLong = tWriteCount;
- } else {
- /* special treatment of variable array */
- /* for test, use always arraysize of VARIABLE_ARRAY_SIZE */
- if (!TIFFGetField( tif, tTag, &unionLong, &pVoidArray)) {
- fprintf (stderr, "Can't read %s\n", tFieldArray->fields[i].field_name);
- GOTOFAILURE_ALL_EXIF
- break;
- }
- /* set tWriteCount to number of read samples for next steps */
- auxLong = unionLong.Short1;
+ /* special treatment of variable array */
+ /* for test, use always arraysize of VARIABLE_ARRAY_SIZE */
+ if (!TIFFGetField(tif, tTag, &unionLong, &pVoidArray)) {
+ fprintf(stderr, "Can't read %s\n", tFieldArray->fields[i].field_name);
+ GOTOFAILURE_ALL_EXIF
+ break;
}
- /* Save values from temporary array */
- if (tSetFieldType == TIFF_SETGET_C0_UINT8 || tSetFieldType == TIFF_SETGET_C0_SINT8 ||
- tSetFieldType == TIFF_SETGET_C16_UINT8 || tSetFieldType == TIFF_SETGET_C16_SINT8 ||
- tSetFieldType == TIFF_SETGET_C32_UINT8 || tSetFieldType == TIFF_SETGET_C32_SINT8 ) {
- memcpy(&auxCharArray, pVoidArray,(auxLong * sizeof(auxCharArray[0])));
- /* Compare and check values */
- for (j=0; j<auxLong; j++) {
- if (tTag == EXIFTAG_EXIFVERSION) {
- /*-- Use exifVersion[] instead of auxCharArrayW[] for differently set EXIFVERSION tag */
- if (auxCharArray[j] != exifVersion[j]) {
- fprintf(stderr, "Read value %d of %s #%d %d differs from set value %d\n", i, tFieldName, j, auxCharArray[j], auxCharArrayW[i + j]);
- GOTOFAILURE_ALL_EXIF
- }
- } else {
- if (auxCharArray[j] != auxCharArrayW[i + j]) {
- fprintf(stderr, "Read value %d of %s #%d %d differs from set value %d\n", i, tFieldName, j, auxCharArray[j], auxCharArrayW[i + j]);
- GOTOFAILURE_ALL_EXIF
- }
- }
- }
- } else if (tSetFieldType == TIFF_SETGET_C0_UINT16 || tSetFieldType == TIFF_SETGET_C0_SINT16 ||
- tSetFieldType == TIFF_SETGET_C16_UINT16 || tSetFieldType == TIFF_SETGET_C16_SINT16 ||
- tSetFieldType == TIFF_SETGET_C32_UINT16 || tSetFieldType == TIFF_SETGET_C32_SINT16 ) {
- memcpy(&auxShortArray, pVoidArray,(auxLong * sizeof(auxShortArray[0])));
- /* Compare and check values */
- for (j=0; j<auxLong; j++) {
- if (auxShortArray[j] != auxShortArrayW[i+j]) {
- fprintf (stderr, "Read value %d of %s #%d %d differs from set value %d\n", i, tFieldName, j, auxShortArray[j], auxShortArrayW[i+j]);
+ /* set tWriteCount to number of read samples for next steps */
+ auxLong = unionLong.Short1;
+ }
+ /* Save values from temporary array */
+ if (tSetFieldType == TIFF_SETGET_C0_UINT8 || tSetFieldType == TIFF_SETGET_C0_SINT8 ||
+ tSetFieldType == TIFF_SETGET_C16_UINT8 || tSetFieldType == TIFF_SETGET_C16_SINT8 ||
+ tSetFieldType == TIFF_SETGET_C32_UINT8 || tSetFieldType == TIFF_SETGET_C32_SINT8) {
+ memcpy(&auxCharArray, pVoidArray, (auxLong * sizeof(auxCharArray[0])));
+ /* Compare and check values */
+ for (j = 0; j < auxLong; j++) {
+ if (tTag == EXIFTAG_EXIFVERSION) {
+ /*-- Use exifVersion[] instead of auxCharArrayW[] for differently set EXIFVERSION tag */
+ if (auxCharArray[j] != exifVersion[j]) {
+ fprintf(stderr, "Read value %d of %s #%d %d differs from set value %d\n", i, tFieldName,
+ j, auxCharArray[j], auxCharArrayW[i + j]);
GOTOFAILURE_ALL_EXIF
}
- }
- } else if (tSetFieldType == TIFF_SETGET_C0_UINT32 || tSetFieldType == TIFF_SETGET_C0_SINT32 ||
- tSetFieldType == TIFF_SETGET_C16_UINT32 || tSetFieldType == TIFF_SETGET_C16_SINT32 ||
- tSetFieldType == TIFF_SETGET_C32_UINT32 || tSetFieldType == TIFF_SETGET_C32_SINT32 ) {
- memcpy(&auxLongArray, pVoidArray,(auxLong * sizeof(auxLongArray[0])));
- /* Compare and check values */
- for (j=0; j<auxLong; j++) {
- if (auxLongArray[j] != auxLongArrayW[i+j]) {
- fprintf (stderr, "Read value %d of %s #%d %ld differs from set value %ld\n", i, tFieldName, j, auxLongArray[j], auxLongArrayW[i+j]);
+ } else {
+ if (auxCharArray[j] != auxCharArrayW[i + j]) {
+ fprintf(stderr, "Read value %d of %s #%d %d differs from set value %d\n", i, tFieldName,
+ j, auxCharArray[j], auxCharArrayW[i + j]);
GOTOFAILURE_ALL_EXIF
}
}
- } else {
- fprintf (stderr, "SetFieldType %d not defined within switch case reading for UINT for %s.\n", tSetFieldType, tFieldName);
- GOTOFAILURE
}
+ } else if (tSetFieldType == TIFF_SETGET_C0_UINT16 || tSetFieldType == TIFF_SETGET_C0_SINT16 ||
+ tSetFieldType == TIFF_SETGET_C16_UINT16 || tSetFieldType == TIFF_SETGET_C16_SINT16 ||
+ tSetFieldType == TIFF_SETGET_C32_UINT16 || tSetFieldType == TIFF_SETGET_C32_SINT16) {
+ memcpy(&auxShortArray, pVoidArray, (auxLong * sizeof(auxShortArray[0])));
+ /* Compare and check values */
+ for (j = 0; j < auxLong; j++) {
+ if (auxShortArray[j] != auxShortArrayW[i + j]) {
+ fprintf(stderr, "Read value %d of %s #%d %d differs from set value %d\n", i, tFieldName, j,
+ auxShortArray[j], auxShortArrayW[i + j]);
+ GOTOFAILURE_ALL_EXIF
+ }
+ }
+ } else if (tSetFieldType == TIFF_SETGET_C0_UINT32 || tSetFieldType == TIFF_SETGET_C0_SINT32 ||
+ tSetFieldType == TIFF_SETGET_C16_UINT32 || tSetFieldType == TIFF_SETGET_C16_SINT32 ||
+ tSetFieldType == TIFF_SETGET_C32_UINT32 || tSetFieldType == TIFF_SETGET_C32_SINT32) {
+ memcpy(&auxLongArray, pVoidArray, (auxLong * sizeof(auxLongArray[0])));
+ /* Compare and check values */
+ for (j = 0; j < auxLong; j++) {
+ if (auxLongArray[j] != auxLongArrayW[i + j]) {
+ fprintf(stderr, "Read value %d of %s #%d %ld differs from set value %ld\n", i, tFieldName,
+ j, auxLongArray[j], auxLongArrayW[i + j]);
+ GOTOFAILURE_ALL_EXIF
+ }
+ }
+ } else {
+ fprintf(stderr, "SetFieldType %d not defined within switch case reading for UINT for %s.\n",
+ tSetFieldType, tFieldName);
+ GOTOFAILURE
}
- break;
- default:
- fprintf (stderr, "SetFieldType %d not defined within writing switch for %s.\n", tSetFieldType, tFieldName);
- GOTOFAILURE
- }; /*-- switch() --*/
+ }
+ }
} /*-- for() --*/
/*================= EXIF: END Reading arbitrary data to the EXIF fields END END END ==============*/
#endif /*-- READ_ALL_EXIF_TAGS --*/
diff --git a/tools/tiff2bw.c b/tools/tiff2bw.c
index 265a932f..acf7bc64 100644
--- a/tools/tiff2bw.c
+++ b/tools/tiff2bw.c
@@ -157,9 +157,12 @@ main(int argc, char* argv[])
break;
case 'h':
usage(EXIT_SUCCESS);
+ /*NOTREACHED*/
+ break;
case '?':
usage(EXIT_FAILURE);
/*NOTREACHED*/
+ break;
}
if (argc - optind < 2)
usage(EXIT_FAILURE);
diff --git a/tools/tiff2pdf.c b/tools/tiff2pdf.c
index 6e956da4..0566c4ad 100644
--- a/tools/tiff2pdf.c
+++ b/tools/tiff2pdf.c
@@ -1015,6 +1015,7 @@ void t2p_free(T2P* t2p)
*/
void t2p_validate(T2P* t2p){
+ (void) t2p;
#ifdef JPEG_SUPPORT
if(t2p->pdf_defaultcompression==T2P_COMPRESS_JPEG){
@@ -1043,7 +1044,6 @@ void t2p_validate(T2P* t2p){
if(t2p->pdf_minorversion<2){t2p->pdf_minorversion=2;}
}
#endif
- (void)0;
return;
}
diff --git a/tools/tiff2ps.c b/tools/tiff2ps.c
index cc5ef955..08e98b56 100644
--- a/tools/tiff2ps.c
+++ b/tools/tiff2ps.c
@@ -2455,7 +2455,13 @@ PSColorSeparatePreamble(FILE* fd, uint32_t w, uint32_t h, int nc)
putc('\n', fd); \
(len) = MAXLINE-(howmany); \
}
-#define PUTHEX(c,fd) putc(hex[((c)>>4)&0xf],fd); putc(hex[(c)&0xf],fd)
+
+static inline void
+puthex(unsigned int c, FILE *fd)
+{
+ putc(hex[((c)>>4)&0xf],fd);
+ putc(hex[(c)&0xf],fd);
+}
void
PSDataColorContig(FILE* fd, TIFF* tif, uint32_t w, uint32_t h, int nc)
@@ -2502,12 +2508,11 @@ PSDataColorContig(FILE* fd, TIFF* tif, uint32_t w, uint32_t h, int nc)
* where Cback = 1.
*/
adjust = 255 - cp[nc];
- switch (nc) {
- case 4: c = *cp++ + adjust; PUTHEX(c,fd);
- case 3: c = *cp++ + adjust; PUTHEX(c,fd);
- case 2: c = *cp++ + adjust; PUTHEX(c,fd);
- case 1: c = *cp++ + adjust; PUTHEX(c,fd);
- }
+ for (int i = 0; i < nc; ++i)
+ {
+ c = *cp++ + adjust;
+ puthex(c,fd);
+ }
cp += es;
}
} else {
@@ -2516,12 +2521,11 @@ PSDataColorContig(FILE* fd, TIFF* tif, uint32_t w, uint32_t h, int nc)
*/
for (cc = 0; (cc + nc) <= tf_bytesperrow; cc += samplesperpixel) {
DOBREAK(breaklen, nc, fd);
- switch (nc) {
- case 4: c = *cp++; PUTHEX(c,fd);
- case 3: c = *cp++; PUTHEX(c,fd);
- case 2: c = *cp++; PUTHEX(c,fd);
- case 1: c = *cp++; PUTHEX(c,fd);
- }
+ for (int i = 0; i < nc; ++i)
+ {
+ c = *cp++;
+ puthex(c,fd);
+ }
cp += es;
}
}
@@ -2553,7 +2557,7 @@ PSDataColorSeparate(FILE* fd, TIFF* tif, uint32_t w, uint32_t h, int nc)
for (cp = tf_buf, cc = 0; cc < tf_bytesperrow; cc++) {
DOBREAK(breaklen, 1, fd);
c = *cp++;
- PUTHEX(c,fd);
+ puthex(c,fd);
}
}
}
@@ -2562,7 +2566,7 @@ end_loop:
}
#define PUTRGBHEX(c,fd) \
- PUTHEX(rmap[c],fd); PUTHEX(gmap[c],fd); PUTHEX(bmap[c],fd)
+ puthex(rmap[c],fd); puthex(gmap[c],fd); puthex(bmap[c],fd)
void
PSDataPalette(FILE* fd, TIFF* tif, uint32_t w, uint32_t h)
@@ -2739,14 +2743,14 @@ PSDataBW(FILE* fd, TIFF* tif, uint32_t w, uint32_t h)
* where Cback = 1.
*/
adjust = 255 - cp[1];
- c = *cp++ + adjust; PUTHEX(c,fd);
+ c = *cp++ + adjust; puthex(c,fd);
cp++, cc--;
}
} else {
while (cc-- > 0) {
c = *cp++;
DOBREAK(breaklen, 1, fd);
- PUTHEX(c, fd);
+ puthex(c, fd);
}
}
}
@@ -2840,7 +2844,7 @@ PSRawDataBW(FILE* fd, TIFF* tif, uint32_t w, uint32_t h)
for (cp = tf_buf; cc > 0; cc--) {
DOBREAK(breaklen, 1, fd);
c = *cp++;
- PUTHEX(c, fd);
+ puthex(c, fd);
}
fputs(">\n", fd);
breaklen = MAXLINE;
diff --git a/tools/tiff2rgba.c b/tools/tiff2rgba.c
index e1495f14..0d8749e0 100644
--- a/tools/tiff2rgba.c
+++ b/tools/tiff2rgba.c
@@ -119,9 +119,11 @@ main(int argc, char* argv[])
case 'h':
usage(EXIT_SUCCESS);
/*NOTREACHED*/
+ break;
case '?':
usage(EXIT_FAILURE);
/*NOTREACHED*/
+ break;
}
if (argc - optind < 2)
diff --git a/tools/tiffcmp.c b/tools/tiffcmp.c
index c895b374..aeaeae9b 100644
--- a/tools/tiffcmp.c
+++ b/tools/tiffcmp.c
@@ -90,9 +90,11 @@ main(int argc, char* argv[])
break;
case 'h':
usage(EXIT_SUCCESS);
+ break;
case '?':
usage(2);
/*NOTREACHED*/
+ break;
}
if (argc - optind < 2)
usage(2);
diff --git a/tools/tiffcp.c b/tools/tiffcp.c
index e29ed333..79e73242 100644
--- a/tools/tiffcp.c
+++ b/tools/tiffcp.c
@@ -293,9 +293,11 @@ main(int argc, char* argv[])
case 'h':
usage(EXIT_SUCCESS);
/*NOTREACHED*/
+ break;
case '?':
usage(EXIT_FAILURE);
/*NOTREACHED*/
+ break;
}
if (argc - optind < 2)
usage(EXIT_FAILURE);
diff --git a/tools/tiffdither.c b/tools/tiffdither.c
index e240ec35..4a7962d6 100644
--- a/tools/tiffdither.c
+++ b/tools/tiffdither.c
@@ -243,9 +243,12 @@ main(int argc, char* argv[])
break;
case 'h':
usage(EXIT_SUCCESS);
+ /*NOTREACHED*/
+ break;
case '?':
usage(EXIT_FAILURE);
/*NOTREACHED*/
+ break;
}
if (argc - optind < 2)
usage(EXIT_FAILURE);
diff --git a/tools/tiffinfo.c b/tools/tiffinfo.c
index 329c0d31..8303bbf8 100644
--- a/tools/tiffinfo.c
+++ b/tools/tiffinfo.c
@@ -128,10 +128,12 @@ main(int argc, char* argv[])
break;
case 'h':
usage(EXIT_SUCCESS);
- /*NOTREACHED*/
+ /*NOTREACHED*/
+ break;
case '?':
usage(EXIT_FAILURE);
/*NOTREACHED*/
+ break;
}
if (optind >= argc)
usage(EXIT_FAILURE);
diff --git a/tools/tiffmedian.c b/tools/tiffmedian.c
index d3726bc3..b27695b2 100644
--- a/tools/tiffmedian.c
+++ b/tools/tiffmedian.c
@@ -155,9 +155,11 @@ main(int argc, char* argv[])
case 'h':
usage(EXIT_SUCCESS);
/*NOTREACHED*/
+ break;
case '?':
usage(EXIT_FAILURE);
/*NOTREACHED*/
+ break;
}
if (argc - optind != 2)
usage(EXIT_FAILURE);