Merge pull request #936 from rouault/master_warnings

CMake: add stronger warnings for openjp2 lib/bin by default, and error out on declaration-after-statement
This commit is contained in:
Even Rouault 2017-05-23 16:15:55 +02:00 committed by GitHub
commit 53d46fc733
6 changed files with 67 additions and 3 deletions

View File

@ -194,6 +194,7 @@ if(CMAKE_COMPILER_IS_GNUCC)
# set(CMAKE_C_FLAGS "-Wall -std=c99 ${CMAKE_C_FLAGS}") # FIXME: this setting prevented us from setting a coverage build.
# Do not use ffast-math for all build, it would produce incorrect results, only set for release:
set(OPENJPEG_LIBRARY_COMPILE_OPTIONS ${OPENJPEG_LIBRARY_COMPILE_OPTIONS} "$<$<CONFIG:Release>:-ffast-math>")
set(OPENJP2_COMPILE_OPTIONS ${OPENJP2_COMPILE_OPTIONS} "$<$<CONFIG:Release>:-ffast-math>" -Wall -Wextra -Wconversion -Wunused-parameter -Wdeclaration-after-statement -Werror=declaration-after-statement)
endif()
#-----------------------------------------------------------------------------

View File

@ -44,6 +44,9 @@ endif()
# Loop over all executables:
foreach(exe opj_decompress opj_compress opj_dump)
add_executable(${exe} ${exe}.c ${common_SRCS})
if(${CMAKE_VERSION} VERSION_GREATER "2.8.11")
target_compile_options(${exe} PRIVATE ${OPENJP2_COMPILE_OPTIONS})
endif()
target_link_libraries(${exe} ${OPENJPEG_LIBRARY_NAME}
${PNG_LIBNAME} ${TIFF_LIBNAME} ${LCMS_LIBNAME}
)

View File

@ -95,7 +95,7 @@ if(UNIX)
endif()
set_target_properties(${OPENJPEG_LIBRARY_NAME} PROPERTIES ${OPENJPEG_LIBRARY_PROPERTIES})
if(${CMAKE_VERSION} VERSION_GREATER "2.8.11")
target_compile_options(${OPENJPEG_LIBRARY_NAME} PRIVATE ${OPENJPEG_LIBRARY_COMPILE_OPTIONS})
target_compile_options(${OPENJPEG_LIBRARY_NAME} PRIVATE ${OPENJP2_COMPILE_OPTIONS})
endif()
# Install library

View File

@ -48,6 +48,8 @@
/** @name Local static functions */
/*@{*/
#define OPJ_UNUSED(x) (void)x
/**
* Sets up the procedures to do on reading header. Developpers wanting to extend the library can add their own reading procedures.
*/
@ -1791,6 +1793,9 @@ static OPJ_BOOL opj_j2k_calculate_tp(opj_j2k_t *p_j2k,
assert(p_j2k != 00);
assert(p_manager != 00);
OPJ_UNUSED(p_j2k);
OPJ_UNUSED(p_manager);
l_nb_tiles = cp->tw * cp->th;
* p_nb_tiles = 0;
tcp = cp->tcps;
@ -2505,7 +2510,11 @@ static OPJ_BOOL opj_j2k_read_com(opj_j2k_t *p_j2k,
assert(p_j2k != 00);
assert(p_manager != 00);
assert(p_header_data != 00);
(void)p_header_size;
OPJ_UNUSED(p_j2k);
OPJ_UNUSED(p_header_data);
OPJ_UNUSED(p_header_size);
OPJ_UNUSED(p_manager);
return OPJ_TRUE;
}
@ -3284,6 +3293,8 @@ static void opj_j2k_write_poc_in_memory(opj_j2k_t *p_j2k,
assert(p_j2k != 00);
assert(p_manager != 00);
OPJ_UNUSED(p_manager);
l_tcp = &p_j2k->m_cp.tcps[p_j2k->m_current_tile_number];
l_tccp = &l_tcp->tccps[0];
l_image = p_j2k->m_private_image;
@ -3523,6 +3534,8 @@ static OPJ_BOOL opj_j2k_read_crg(opj_j2k_t *p_j2k,
assert(p_j2k != 00);
assert(p_manager != 00);
OPJ_UNUSED(p_header_data);
l_nb_comp = p_j2k->m_private_image->numcomps;
if (p_header_size != l_nb_comp * 4) {
@ -3564,6 +3577,8 @@ static OPJ_BOOL opj_j2k_read_tlm(opj_j2k_t *p_j2k,
assert(p_j2k != 00);
assert(p_manager != 00);
OPJ_UNUSED(p_j2k);
if (p_header_size < 2) {
opj_event_msg(p_manager, EVT_ERROR, "Error reading TLM marker\n");
return OPJ_FALSE;
@ -3621,6 +3636,9 @@ static OPJ_BOOL opj_j2k_read_plm(opj_j2k_t *p_j2k,
assert(p_j2k != 00);
assert(p_manager != 00);
OPJ_UNUSED(p_j2k);
OPJ_UNUSED(p_header_data);
if (p_header_size < 1) {
opj_event_msg(p_manager, EVT_ERROR, "Error reading PLM marker\n");
return OPJ_FALSE;
@ -3693,6 +3711,8 @@ static OPJ_BOOL opj_j2k_read_plt(opj_j2k_t *p_j2k,
assert(p_j2k != 00);
assert(p_manager != 00);
OPJ_UNUSED(p_j2k);
if (p_header_size < 1) {
opj_event_msg(p_manager, EVT_ERROR, "Error reading PLT marker\n");
return OPJ_FALSE;
@ -4156,6 +4176,9 @@ static OPJ_BOOL opj_j2k_write_sot(opj_j2k_t *p_j2k,
assert(p_manager != 00);
assert(p_stream != 00);
OPJ_UNUSED(p_stream);
OPJ_UNUSED(p_manager);
opj_write_bytes(p_data, J2K_MS_SOT,
2); /* SOT */
p_data += 2;
@ -4520,6 +4543,8 @@ static OPJ_BOOL opj_j2k_write_sod(opj_j2k_t *p_j2k,
assert(p_manager != 00);
assert(p_stream != 00);
OPJ_UNUSED(p_stream);
opj_write_bytes(p_data, J2K_MS_SOD,
2); /* SOD */
p_data += 2;
@ -4916,6 +4941,8 @@ static OPJ_BOOL opj_j2k_update_rates(opj_j2k_t *p_j2k,
assert(p_manager != 00);
assert(p_stream != 00);
OPJ_UNUSED(p_manager);
l_cp = &(p_j2k->m_cp);
l_image = p_j2k->m_private_image;
l_tcp = l_cp->tcps;
@ -5124,6 +5151,8 @@ static OPJ_BOOL opj_j2k_get_end_header(opj_j2k_t *p_j2k,
assert(p_manager != 00);
assert(p_stream != 00);
OPJ_UNUSED(p_manager);
p_j2k->cstr_index->main_head_end = opj_stream_tell(p_stream);
return OPJ_TRUE;
@ -5264,6 +5293,8 @@ static OPJ_BOOL opj_j2k_write_epc(opj_j2k_t *p_j2k,
assert(p_manager != 00);
assert(p_stream != 00);
OPJ_UNUSED(p_manager);
l_cstr_index = p_j2k->cstr_index;
if (l_cstr_index) {
l_cstr_index->codestream_size = (OPJ_UINT64)opj_stream_tell(p_stream);
@ -7291,6 +7322,9 @@ static OPJ_BOOL opj_j2k_mct_validation(opj_j2k_t * p_j2k,
assert(p_stream != 00);
assert(p_manager != 00);
OPJ_UNUSED(p_stream);
OPJ_UNUSED(p_manager);
if ((p_j2k->m_cp.rsiz & 0x8200) == 0x8200) {
OPJ_UINT32 l_nb_tiles = p_j2k->m_cp.th * p_j2k->m_cp.tw;
opj_tcp_t * l_tcp = p_j2k->m_cp.tcps;
@ -7510,6 +7544,8 @@ static OPJ_BOOL opj_j2k_encoding_validation(opj_j2k_t * p_j2k,
assert(p_stream != 00);
assert(p_manager != 00);
OPJ_UNUSED(p_stream);
/* STATE checking */
/* make sure the state is at 0 */
l_is_valid &= (p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_NONE);
@ -7560,6 +7596,9 @@ static OPJ_BOOL opj_j2k_decoding_validation(opj_j2k_t *p_j2k,
assert(p_stream != 00);
assert(p_manager != 00);
OPJ_UNUSED(p_stream);
OPJ_UNUSED(p_manager);
/* STATE checking */
/* make sure the state is at 0 */
#ifdef TODO_MSD
@ -7813,6 +7852,8 @@ static OPJ_BOOL opj_j2k_copy_default_tcp_and_create_tcd(opj_j2k_t * p_j2k,
assert(p_stream != 00);
assert(p_manager != 00);
OPJ_UNUSED(p_stream);
l_image = p_j2k->m_private_image;
l_nb_tiles = p_j2k->m_cp.th * p_j2k->m_cp.tw;
l_tcp = p_j2k->m_cp.tcps;
@ -11442,6 +11483,9 @@ static OPJ_BOOL opj_j2k_end_encoding(opj_j2k_t *p_j2k,
assert(p_manager != 00);
assert(p_stream != 00);
OPJ_UNUSED(p_stream);
OPJ_UNUSED(p_manager);
opj_tcd_destroy(p_j2k->m_tcd);
p_j2k->m_tcd = 00;
@ -11474,6 +11518,9 @@ static OPJ_BOOL opj_j2k_destroy_header_memory(opj_j2k_t * p_j2k,
assert(p_stream != 00);
assert(p_manager != 00);
OPJ_UNUSED(p_stream);
OPJ_UNUSED(p_manager);
if (p_j2k->m_specific_param.m_encoder.m_header_tile_data) {
opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data);
p_j2k->m_specific_param.m_encoder.m_header_tile_data = 0;
@ -11496,6 +11543,8 @@ static OPJ_BOOL opj_j2k_init_info(opj_j2k_t *p_j2k,
assert(p_stream != 00);
(void)l_cstr_info;
OPJ_UNUSED(p_stream);
/* TODO mergeV2: check this part which use cstr_info */
/*l_cstr_info = p_j2k->cstr_info;
@ -11557,6 +11606,8 @@ static OPJ_BOOL opj_j2k_create_tcd(opj_j2k_t *p_j2k,
assert(p_manager != 00);
assert(p_stream != 00);
OPJ_UNUSED(p_stream);
p_j2k->m_tcd = opj_tcd_create(OPJ_FALSE);
if (! p_j2k->m_tcd) {

View File

@ -44,6 +44,8 @@
#define OPJ_BOX_SIZE 1024
#define OPJ_UNUSED(x) (void)x
/** @name Local static functions */
/*@{*/
@ -1818,6 +1820,8 @@ static OPJ_BOOL opj_jp2_write_jp(opj_jp2_t *jp2,
assert(jp2 != 00);
assert(p_manager != 00);
OPJ_UNUSED(jp2);
/* write box length */
opj_write_bytes(l_signature_data, 12, 4);
/* writes box type */
@ -2160,6 +2164,8 @@ static OPJ_BOOL opj_jp2_default_validation(opj_jp2_t * jp2,
assert(cio != 00);
assert(p_manager != 00);
OPJ_UNUSED(p_manager);
/* JPEG2000 codec validation */
/* STATE checking */
@ -2826,6 +2832,9 @@ static OPJ_BOOL opj_jp2_setup_decoding_validation(opj_jp2_t *jp2,
assert(jp2 != 00);
assert(p_manager != 00);
OPJ_UNUSED(jp2);
OPJ_UNUSED(p_manager);
/* DEVELOPER CORNER, add your custom validation procedure */
return OPJ_TRUE;

View File

@ -19,7 +19,7 @@ if("$ENV{TRAVIS_OS_NAME}" STREQUAL "windows")
set( JPYLYZER_EXT "exe" )
else()
set( CTEST_CMAKE_GENERATOR "Unix Makefiles") # Always makefile in travis-ci environment
set( CCFLAGS_WARNING "-Wall -Wextra -Wconversion -Wno-unused-parameter -Wdeclaration-after-statement")
set( CCFLAGS_WARNING "-Wall -Wextra -Wconversion -Wno-unused-parameter -Wdeclaration-after-statement -Werror=declaration-after-statement")
set( JPYLYZER_EXT "py" )
endif()