diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2003-07-16 16:29:32 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2003-07-16 16:29:32 (GMT) |
commit | 4ddde287dc94d235c1b981488ccbca1c31324f2f (patch) | |
tree | 071a2cd36cae1b793490ac39a781fd5bf9c900e2 /src/H5Zszip.c | |
parent | e9cc951e034865fb1f2e9dc0385ed34072675bba (diff) | |
download | hdf5-4ddde287dc94d235c1b981488ccbca1c31324f2f.zip hdf5-4ddde287dc94d235c1b981488ccbca1c31324f2f.tar.gz hdf5-4ddde287dc94d235c1b981488ccbca1c31324f2f.tar.bz2 |
[svn-r7236] Purpose:
Code cleanup
Description:
Clean up more warnings from lint.
Platforms tested:
FreeBSD 4.8 (sleipnir)
too minor for h5committest
Diffstat (limited to 'src/H5Zszip.c')
-rw-r--r-- | src/H5Zszip.c | 68 |
1 files changed, 35 insertions, 33 deletions
diff --git a/src/H5Zszip.c b/src/H5Zszip.c index bf3bcda..decf0d3 100644 --- a/src/H5Zszip.c +++ b/src/H5Zszip.c @@ -89,56 +89,57 @@ H5Z_can_apply_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id) unsigned cd_values[H5Z_SZIP_TOTAL_NPARMS]; /* Filter parameters */ hsize_t dims[H5O_LAYOUT_NDIMS]; /* Dataspace (i.e. chunk) dimensions */ int ndims; /* Number of (chunk) dimensions */ - int dtype_size; /* Datatype's size (in bits) */ + unsigned dtype_size; /* Datatype's size (in bits) */ H5T_order_t dtype_order; /* Datatype's endianness order */ hsize_t scanline; /* Size of dataspace's fastest changing dimension */ herr_t ret_value=TRUE; /* Return value */ - FUNC_ENTER_NOAPI(H5Z_can_apply_szip, FAIL); + FUNC_ENTER_NOAPI(H5Z_can_apply_szip, FAIL) /* Get the filter's current parameters */ if(H5Pget_filter_by_id(dcpl_id,H5Z_FILTER_SZIP,&flags,&cd_nelmts, cd_values,0,NULL)<0) - HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't get szip parameters"); + HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't get szip parameters") /* Check that no parameters are currently set */ if(cd_nelmts!=H5Z_SZIP_USER_NPARMS) - HGOTO_ERROR(H5E_PLINE, H5E_BADVALUE, FAIL, "incorrect # of szip parameters"); + HGOTO_ERROR(H5E_PLINE, H5E_BADVALUE, FAIL, "incorrect # of szip parameters") /* Get datatype's size, for checking the "bits-per-pixel" */ if((dtype_size=(sizeof(unsigned char)*H5Tget_size(type_id)))==0) - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size"); + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size") /* Range check datatype's size */ if(dtype_size>32 && dtype_size!=64) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FALSE, "invalid datatype size"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FALSE, "invalid datatype size") /* Get datatype's endianness order */ if((dtype_order=H5Tget_order(type_id))==H5T_ORDER_ERROR) - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "can't retrieve datatype endianness order"); + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "can't retrieve datatype endianness order") /* Range check datatype's endianness order */ /* (Note: this may not handle non-atomic datatypes well) */ if(dtype_order != H5T_ORDER_LE && dtype_order != H5T_ORDER_BE) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FALSE, "invalid datatype endianness order"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FALSE, "invalid datatype endianness order") /* Get dimensions for dataspace */ if ((ndims=H5Sget_simple_extent_dims(space_id, dims, NULL))<0) - HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "unable to get dataspace dimensions"); + HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "unable to get dataspace dimensions") /* Get "local" parameter for this dataset's "pixels-per-scanline" */ /* (Use the chunk's fastest changing dimension size) */ + assert(ndims>0); scanline=dims[ndims-1]; /* Range check the scanline's size */ if(scanline > SZ_MAX_PIXELS_PER_SCANLINE) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FALSE, "invalid scanline size"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FALSE, "invalid scanline size") /* Range check the scanline's number of blocks */ if((scanline/cd_values[H5Z_SZIP_PARM_PPB]) > SZ_MAX_BLOCKS_PER_SCANLINE) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FALSE, "invalid number of blocks per scanline"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FALSE, "invalid number of blocks per scanline") done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_can_apply_szip() */ @@ -168,31 +169,32 @@ H5Z_set_local_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id) H5T_order_t dtype_order; /* Datatype's endianness order */ herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5Z_set_local_szip, FAIL); + FUNC_ENTER_NOAPI(H5Z_set_local_szip, FAIL) /* Get the filter's current parameters */ if(H5Pget_filter_by_id(dcpl_id,H5Z_FILTER_SZIP,&flags,&cd_nelmts, cd_values,0,NULL)<0) - HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't get szip parameters"); + HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't get szip parameters") /* Check that no parameters are currently set */ if(cd_nelmts!=H5Z_SZIP_USER_NPARMS) - HGOTO_ERROR(H5E_PLINE, H5E_BADVALUE, FAIL, "incorrect # of szip parameters"); + HGOTO_ERROR(H5E_PLINE, H5E_BADVALUE, FAIL, "incorrect # of szip parameters") /* Get dimensions for dataspace */ if ((ndims=H5Sget_simple_extent_dims(space_id, dims, NULL))<0) - HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "unable to get dataspace dimensions"); + HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "unable to get dataspace dimensions") /* Set "local" parameter for this dataset's "bits-per-pixel" */ if((cd_values[H5Z_SZIP_PARM_BPP]=(8*sizeof(unsigned char)*H5Tget_size(type_id)))==0) - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size"); + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size") /* Set "local" parameter for this dataset's "pixels-per-scanline" */ /* (Use the chunk's fastest changing dimension size) */ - cd_values[H5Z_SZIP_PARM_PPS]=dims[ndims-1]; + assert(ndims>0); + H5_ASSIGN_OVERFLOW(cd_values[H5Z_SZIP_PARM_PPS],dims[ndims-1],hsize_t,unsigned); /* Get datatype's endianness order */ if((dtype_order=H5Tget_order(type_id))==H5T_ORDER_ERROR) - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype endianness order"); + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype endianness order") /* Set the correct endianness flag for szip */ /* (Note: this may not handle non-atomic datatypes well) */ @@ -206,15 +208,15 @@ H5Z_set_local_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id) break; default: - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype endianness order"); + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype endianness order") } /* end switch */ /* Modify the filter's parameters for this dataset */ if(H5Pmodify_filter(dcpl_id, H5Z_FILTER_SZIP, flags, H5Z_SZIP_TOTAL_NPARMS, cd_values)<0) - HGOTO_ERROR(H5E_PLINE, H5E_CANTSET, FAIL, "can't set local szip parameters"); + HGOTO_ERROR(H5E_PLINE, H5E_CANTSET, FAIL, "can't set local szip parameters") done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_set_local_szip() */ @@ -246,7 +248,7 @@ H5Z_filter_szip (unsigned flags, size_t cd_nelmts, const unsigned cd_values[], unsigned char *newbuf = NULL; /* Pointer to input buffer */ SZ_com_t sz_param; /* szip parameter block */ - FUNC_ENTER_NOAPI(H5Z_filter_szip, 0); + FUNC_ENTER_NOAPI(H5Z_filter_szip, 0) /* Sanity check to make certain that we haven't drifted out of date with * the mask options from the szlib.h header */ @@ -260,13 +262,13 @@ H5Z_filter_szip (unsigned flags, size_t cd_nelmts, const unsigned cd_values[], /* Check arguments */ if (cd_nelmts!=4) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid deflate aggression level"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid deflate aggression level") /* Copy the filter parameters into the szip parameter block */ - sz_param.options_mask = cd_values[H5Z_SZIP_PARM_MASK]; - sz_param.bits_per_pixel = cd_values[H5Z_SZIP_PARM_BPP]; - sz_param.pixels_per_block = cd_values[H5Z_SZIP_PARM_PPB]; - sz_param.pixels_per_scanline = cd_values[H5Z_SZIP_PARM_PPS]; + H5_ASSIGN_OVERFLOW(sz_param.options_mask,cd_values[H5Z_SZIP_PARM_MASK],unsigned,int); + H5_ASSIGN_OVERFLOW(sz_param.bits_per_pixel,cd_values[H5Z_SZIP_PARM_BPP],unsigned,int); + H5_ASSIGN_OVERFLOW(sz_param.pixels_per_block,cd_values[H5Z_SZIP_PARM_PPB],unsigned,int); + H5_ASSIGN_OVERFLOW(sz_param.pixels_per_scanline,cd_values[H5Z_SZIP_PARM_PPS],unsigned,int); /* Input; uncompress */ if (flags & H5Z_FLAG_REVERSE) { @@ -280,12 +282,12 @@ H5Z_filter_szip (unsigned flags, size_t cd_nelmts, const unsigned cd_values[], /* Allocate space for the uncompressed buffer */ if(NULL==(outbuf = H5MM_malloc(nalloc))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed for szip decompression"); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed for szip decompression") /* Decompress the buffer */ size_out=nalloc; if(SZ_BufftoBuffDecompress(outbuf, &size_out, newbuf, nbytes-4, &sz_param) != SZ_OK) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "szip_filter: decompression failed"); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "szip_filter: decompression failed") assert(size_out==nalloc); /* Free the input buffer */ @@ -303,7 +305,7 @@ H5Z_filter_szip (unsigned flags, size_t cd_nelmts, const unsigned cd_values[], /* Allocate space for the compressed buffer & header (assume data won't get bigger) */ if(NULL==(dst=outbuf = H5MM_malloc(nbytes+4))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "unable to allocate szip destination buffer"); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "unable to allocate szip destination buffer") /* Encode the uncompressed length */ H5_CHECK_OVERFLOW(nbytes,size_t,uint32_t); @@ -312,7 +314,7 @@ H5Z_filter_szip (unsigned flags, size_t cd_nelmts, const unsigned cd_values[], /* Compress the buffer */ size_out = nbytes; if(SZ_OK!= SZ_BufftoBuffCompress(dst, &size_out, *buf, nbytes, &sz_param)) - HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, 0, "overflow"); + HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, 0, "overflow") assert(size_out<=nbytes); /* Free the input buffer */ @@ -328,7 +330,7 @@ H5Z_filter_szip (unsigned flags, size_t cd_nelmts, const unsigned cd_values[], done: if(outbuf) H5MM_xfree(outbuf); - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } #endif /* H5_HAVE_FILTER_SZIP */ |