Fix warnings and errors when compiling with a c++ compiler (#1021)
authorEven Rouault <even.rouault@spatialys.com>
Tue, 19 Sep 2017 10:46:20 +0000 (12:46 +0200)
committerEven Rouault <even.rouault@spatialys.com>
Tue, 19 Sep 2017 10:46:20 +0000 (12:46 +0200)
src/lib/openjp2/bench_dwt.c
src/lib/openjp2/sparse_array.c
src/lib/openjp2/t1.c
src/lib/openjp2/tcd.c

index 0dc278f3ec8ae83b76fe08bf287a554033107936..103b681aeadbcd88f911e3872fad7b706cd1aa80 100644 (file)
@@ -62,13 +62,14 @@ void init_tilec(opj_tcd_tilecomp_t * l_tilec,
     l_tilec->y1 = y1;
     nValues = (size_t)(l_tilec->x1 - l_tilec->x0) *
               (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++) {
         l_tilec->data[i] = getValue((OPJ_UINT32)i);
     }
     l_tilec->numresolutions = numresolutions;
-    l_tilec->resolutions = opj_calloc(l_tilec->numresolutions,
-                                      sizeof(opj_tcd_resolution_t));
+    l_tilec->resolutions = (opj_tcd_resolution_t*) opj_calloc(
+                               l_tilec->numresolutions,
+                               sizeof(opj_tcd_resolution_t));
 
     l_level_no = l_tilec->numresolutions;
     l_res = l_tilec->resolutions;
index 6a2d8d4349767a0fba2662f9afff4b30f7980b6c..67212d28b9223b06b3a7bd1590de0efcb7ce16b9 100644 (file)
@@ -56,7 +56,8 @@ opj_sparse_array_int32_t* opj_sparse_array_int32_create(OPJ_UINT32 width,
         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->height = height;
     sa->block_width = block_width;
@@ -67,8 +68,8 @@ opj_sparse_array_int32_t* opj_sparse_array_int32_create(OPJ_UINT32 width,
         opj_free(sa);
         return NULL;
     }
-    sa->data_blocks = opj_calloc(sizeof(OPJ_INT32*),
-                                 sa->block_count_hor * sa->block_count_ver);
+    sa->data_blocks = (OPJ_INT32**) opj_calloc(sizeof(OPJ_INT32*),
+                      sa->block_count_hor * sa->block_count_ver);
     if (sa->data_blocks == NULL) {
         opj_free(sa);
         return NULL;
@@ -232,8 +233,8 @@ static OPJ_BOOL opj_sparse_array_int32_read_or_write(
                 }
             } else {
                 if (src_block == NULL) {
-                    src_block = opj_calloc(1,
-                                           sa->block_width * sa->block_height * sizeof(OPJ_INT32));
+                    src_block = (OPJ_INT32*) opj_calloc(1,
+                                                        sa->block_width * sa->block_height * sizeof(OPJ_INT32));
                     if (src_block == NULL) {
                         return OPJ_FALSE;
                     }
index a583e692088be2834fe9628398661f698271149c..e96998534307bcaea2b8740f98fb9a5b5df7ce2c 100644 (file)
@@ -1065,6 +1065,7 @@ static void opj_t1_enc_clnpass_step(
     for (ci = runlen; ci < lim; ++ci) {
         OPJ_UINT32 vsc;
         opj_flag_t flags;
+        OPJ_UINT32 ctxt1;
 
         flags = *flagsp;
 
@@ -1073,7 +1074,7 @@ static void opj_t1_enc_clnpass_step(
         }
 
         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
             printf("   ctxt1=%d\n", ctxt1);
 #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_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 (job->p_manager_mutex) {
                 opj_mutex_lock(job->p_manager_mutex);
index 631a48400497e92a20d24c900a6c9edf8f678697..fad9d23c02039d2b5a9b824aa5aeee218741b7c3 100644 (file)
@@ -1614,7 +1614,7 @@ OPJ_BOOL opj_tcd_decode_tile(opj_tcd_t *p_tcd,
                 }
                 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) {
                     opj_event_msg(p_manager, EVT_ERROR,
                                   "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;
         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) {
                 l_band = l_res->bands;
                 for (bandno = 0; bandno < 3; ++bandno) {
                     l_precinct = l_band->precincts;
                     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) {
                             opj_tgt_destroy(l_precinct->incltree);
                             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_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);*/
 
         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;
     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)  {
             if (l_code_block->data) {