Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake: add stronger warnings for openjp2 lib/bin by default, and error out on declaration-after-statement #936

Merged
merged 1 commit into from
May 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

#-----------------------------------------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions src/bin/jp2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
)
Expand Down
2 changes: 1 addition & 1 deletion src/lib/openjp2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
53 changes: 52 additions & 1 deletion src/lib/openjp2/j2k.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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) {
Expand Down
9 changes: 9 additions & 0 deletions src/lib/openjp2/jp2.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@

#define OPJ_BOX_SIZE 1024

#define OPJ_UNUSED(x) (void)x

/** @name Local static functions */
/*@{*/

Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tools/ctest_scripts/travis-ci.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down