Fix warnings and errors when compiling with a c++ compiler (#1021)

This commit is contained in:
Even Rouault 2017-09-19 12:46:20 +02:00
parent 18f6696372
commit fdef69b43c
4 changed files with 23 additions and 15 deletions

View File

@ -62,12 +62,13 @@ void init_tilec(opj_tcd_tilecomp_t * l_tilec,
l_tilec->y1 = y1; l_tilec->y1 = y1;
nValues = (size_t)(l_tilec->x1 - l_tilec->x0) * nValues = (size_t)(l_tilec->x1 - l_tilec->x0) *
(size_t)(l_tilec->y1 - l_tilec->y0); (size_t)(l_tilec->y1 - l_tilec->y0);
l_tilec->data = opj_malloc(sizeof(OPJ_INT32) * nValues); l_tilec->data = (OPJ_INT32*) opj_malloc(sizeof(OPJ_INT32) * nValues);
for (i = 0; i < nValues; i++) { for (i = 0; i < nValues; i++) {
l_tilec->data[i] = getValue((OPJ_UINT32)i); l_tilec->data[i] = getValue((OPJ_UINT32)i);
} }
l_tilec->numresolutions = numresolutions; l_tilec->numresolutions = numresolutions;
l_tilec->resolutions = opj_calloc(l_tilec->numresolutions, l_tilec->resolutions = (opj_tcd_resolution_t*) opj_calloc(
l_tilec->numresolutions,
sizeof(opj_tcd_resolution_t)); sizeof(opj_tcd_resolution_t));
l_level_no = l_tilec->numresolutions; l_level_no = l_tilec->numresolutions;

View File

@ -56,7 +56,8 @@ opj_sparse_array_int32_t* opj_sparse_array_int32_create(OPJ_UINT32 width,
return NULL; return NULL;
} }
sa = opj_calloc(1, sizeof(opj_sparse_array_int32_t)); sa = (opj_sparse_array_int32_t*) opj_calloc(1,
sizeof(opj_sparse_array_int32_t));
sa->width = width; sa->width = width;
sa->height = height; sa->height = height;
sa->block_width = block_width; sa->block_width = block_width;
@ -67,7 +68,7 @@ opj_sparse_array_int32_t* opj_sparse_array_int32_create(OPJ_UINT32 width,
opj_free(sa); opj_free(sa);
return NULL; return NULL;
} }
sa->data_blocks = opj_calloc(sizeof(OPJ_INT32*), sa->data_blocks = (OPJ_INT32**) opj_calloc(sizeof(OPJ_INT32*),
sa->block_count_hor * sa->block_count_ver); sa->block_count_hor * sa->block_count_ver);
if (sa->data_blocks == NULL) { if (sa->data_blocks == NULL) {
opj_free(sa); opj_free(sa);
@ -232,7 +233,7 @@ static OPJ_BOOL opj_sparse_array_int32_read_or_write(
} }
} else { } else {
if (src_block == NULL) { if (src_block == NULL) {
src_block = opj_calloc(1, src_block = (OPJ_INT32*) opj_calloc(1,
sa->block_width * sa->block_height * sizeof(OPJ_INT32)); sa->block_width * sa->block_height * sizeof(OPJ_INT32));
if (src_block == NULL) { if (src_block == NULL) {
return OPJ_FALSE; return OPJ_FALSE;

View File

@ -1065,6 +1065,7 @@ static void opj_t1_enc_clnpass_step(
for (ci = runlen; ci < lim; ++ci) { for (ci = runlen; ci < lim; ++ci) {
OPJ_UINT32 vsc; OPJ_UINT32 vsc;
opj_flag_t flags; opj_flag_t flags;
OPJ_UINT32 ctxt1;
flags = *flagsp; flags = *flagsp;
@ -1073,7 +1074,7 @@ static void opj_t1_enc_clnpass_step(
} }
if (!(flags & ((T1_SIGMA_THIS | T1_PI_THIS) << (ci * 3U)))) { if (!(flags & ((T1_SIGMA_THIS | T1_PI_THIS) << (ci * 3U)))) {
OPJ_UINT32 ctxt1 = opj_t1_getctxno_zc(mqc, flags >> (ci * 3U)); ctxt1 = opj_t1_getctxno_zc(mqc, flags >> (ci * 3U));
#ifdef DEBUG_ENC_CLN #ifdef DEBUG_ENC_CLN
printf(" ctxt1=%d\n", ctxt1); printf(" ctxt1=%d\n", ctxt1);
#endif #endif
@ -1617,7 +1618,8 @@ static void opj_t1_clbl_decode_processor(void* user_data, opj_tls_t* tls)
cblk_w = (OPJ_UINT32)(cblk->x1 - cblk->x0); cblk_w = (OPJ_UINT32)(cblk->x1 - cblk->x0);
cblk_h = (OPJ_UINT32)(cblk->y1 - cblk->y0); cblk_h = (OPJ_UINT32)(cblk->y1 - cblk->y0);
cblk->decoded_data = opj_aligned_malloc(cblk_w * cblk_h * sizeof(OPJ_INT32)); cblk->decoded_data = (OPJ_INT32*)opj_aligned_malloc(cblk_w * cblk_h * sizeof(
OPJ_INT32));
if (cblk->decoded_data == NULL) { if (cblk->decoded_data == NULL) {
if (job->p_manager_mutex) { if (job->p_manager_mutex) {
opj_mutex_lock(job->p_manager_mutex); opj_mutex_lock(job->p_manager_mutex);

View File

@ -1614,7 +1614,7 @@ OPJ_BOOL opj_tcd_decode_tile(opj_tcd_t *p_tcd,
} }
l_data_size *= sizeof(OPJ_INT32); l_data_size *= sizeof(OPJ_INT32);
tilec->data_win = opj_image_data_alloc(l_data_size); tilec->data_win = (OPJ_INT32*) opj_image_data_alloc(l_data_size);
if (tilec->data_win == NULL) { if (tilec->data_win == NULL) {
opj_event_msg(p_manager, EVT_ERROR, opj_event_msg(p_manager, EVT_ERROR,
"Size of tile data exceeds system limits\n"); "Size of tile data exceeds system limits\n");
@ -1812,14 +1812,16 @@ static void opj_tcd_free_tile(opj_tcd_t *p_tcd)
l_res = l_tile_comp->resolutions; l_res = l_tile_comp->resolutions;
if (l_res) { if (l_res) {
l_nb_resolutions = l_tile_comp->resolutions_size / sizeof(opj_tcd_resolution_t); l_nb_resolutions = l_tile_comp->resolutions_size / (OPJ_UINT32)sizeof(
opj_tcd_resolution_t);
for (resno = 0; resno < l_nb_resolutions; ++resno) { for (resno = 0; resno < l_nb_resolutions; ++resno) {
l_band = l_res->bands; l_band = l_res->bands;
for (bandno = 0; bandno < 3; ++bandno) { for (bandno = 0; bandno < 3; ++bandno) {
l_precinct = l_band->precincts; l_precinct = l_band->precincts;
if (l_precinct) { if (l_precinct) {
l_nb_precincts = l_band->precincts_data_size / sizeof(opj_tcd_precinct_t); l_nb_precincts = l_band->precincts_data_size / (OPJ_UINT32)sizeof(
opj_tcd_precinct_t);
for (precno = 0; precno < l_nb_precincts; ++precno) { for (precno = 0; precno < l_nb_precincts; ++precno) {
opj_tgt_destroy(l_precinct->incltree); opj_tgt_destroy(l_precinct->incltree);
l_precinct->incltree = 00; l_precinct->incltree = 00;
@ -2215,7 +2217,8 @@ static void opj_tcd_code_block_dec_deallocate(opj_tcd_precinct_t * p_precinct)
l_code_block->numbps, l_code_block->numlenbits, l_code_block->len, l_code_block->numnewpasses, l_code_block->real_num_segs, l_code_block->m_current_max_segs );*/ l_code_block->numbps, l_code_block->numlenbits, l_code_block->len, l_code_block->numnewpasses, l_code_block->real_num_segs, l_code_block->m_current_max_segs );*/
l_nb_code_blocks = p_precinct->block_size / sizeof(opj_tcd_cblk_dec_t); l_nb_code_blocks = p_precinct->block_size / (OPJ_UINT32)sizeof(
opj_tcd_cblk_dec_t);
/*fprintf(stderr,"nb_code_blocks =%d\t}\n", l_nb_code_blocks);*/ /*fprintf(stderr,"nb_code_blocks =%d\t}\n", l_nb_code_blocks);*/
for (cblkno = 0; cblkno < l_nb_code_blocks; ++cblkno) { for (cblkno = 0; cblkno < l_nb_code_blocks; ++cblkno) {
@ -2250,7 +2253,8 @@ static void opj_tcd_code_block_enc_deallocate(opj_tcd_precinct_t * p_precinct)
opj_tcd_cblk_enc_t * l_code_block = p_precinct->cblks.enc; opj_tcd_cblk_enc_t * l_code_block = p_precinct->cblks.enc;
if (l_code_block) { if (l_code_block) {
l_nb_code_blocks = p_precinct->block_size / sizeof(opj_tcd_cblk_enc_t); l_nb_code_blocks = p_precinct->block_size / (OPJ_UINT32)sizeof(
opj_tcd_cblk_enc_t);
for (cblkno = 0; cblkno < l_nb_code_blocks; ++cblkno) { for (cblkno = 0; cblkno < l_nb_code_blocks; ++cblkno) {
if (l_code_block->data) { if (l_code_block->data) {