summaryrefslogtreecommitdiffstats
path: root/src/H5Zdeflate.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2003-07-16 16:29:32 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2003-07-16 16:29:32 (GMT)
commit4ddde287dc94d235c1b981488ccbca1c31324f2f (patch)
tree071a2cd36cae1b793490ac39a781fd5bf9c900e2 /src/H5Zdeflate.c
parente9cc951e034865fb1f2e9dc0385ed34072675bba (diff)
downloadhdf5-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/H5Zdeflate.c')
-rw-r--r--src/H5Zdeflate.c66
1 files changed, 33 insertions, 33 deletions
diff --git a/src/H5Zdeflate.c b/src/H5Zdeflate.c
index 89f15cc..80004f7 100644
--- a/src/H5Zdeflate.c
+++ b/src/H5Zdeflate.c
@@ -76,11 +76,11 @@ H5Z_filter_deflate (unsigned flags, size_t cd_nelmts,
int status; /* Status from zlib operation */
size_t ret_value; /* Return value */
- FUNC_ENTER_NOAPI(H5Z_filter_deflate, 0);
+ FUNC_ENTER_NOAPI(H5Z_filter_deflate, 0)
/* Check arguments */
if (cd_nelmts!=1 || cd_values[0]>9)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid deflate aggression level");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid deflate aggression level")
if (flags & H5Z_FLAG_REVERSE) {
/* Input; uncompress */
@@ -89,7 +89,7 @@ H5Z_filter_deflate (unsigned flags, size_t cd_nelmts,
/* Allocate space for the compressed buffer */
if (NULL==(outbuf = H5MM_malloc(nalloc)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed for deflate uncompression");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed for deflate uncompression")
/* Set the uncompression parameters */
HDmemset(&z_strm, 0, sizeof(z_strm));
@@ -100,10 +100,10 @@ H5Z_filter_deflate (unsigned flags, size_t cd_nelmts,
/* Initialize the uncompression routines */
if (Z_OK!=inflateInit(&z_strm))
- HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, 0, "inflateInit() failed");
+ HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, 0, "inflateInit() failed")
/* Loop to uncompress the buffer */
- while (1) {
+ do {
/* Uncompress some data */
status = inflate(&z_strm, Z_SYNC_FLUSH);
@@ -113,24 +113,25 @@ H5Z_filter_deflate (unsigned flags, size_t cd_nelmts,
/* Check for error */
if (Z_OK!=status) {
- inflateEnd(&z_strm);
- HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, 0, "inflate() failed");
+ (void)inflateEnd(&z_strm);
+ HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, 0, "inflate() failed")
}
-
- /* If we're not done and just ran out of buffer space, get more */
- if (Z_OK==status && 0==z_strm.avail_out) {
- /* Allocate a buffer twice as big */
- nalloc *= 2;
- if (NULL==(outbuf = H5MM_realloc(outbuf, nalloc))) {
- inflateEnd(&z_strm);
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed for deflate uncompression");
- }
-
- /* Update pointers to buffer for next set of uncompressed data */
- z_strm.next_out = (unsigned char*)outbuf + z_strm.total_out;
- z_strm.avail_out = (uInt)(nalloc - z_strm.total_out);
- }
- }
+ else {
+ /* If we're not done and just ran out of buffer space, get more */
+ if (0==z_strm.avail_out) {
+ /* Allocate a buffer twice as big */
+ nalloc *= 2;
+ if (NULL==(outbuf = H5MM_realloc(outbuf, nalloc))) {
+ (void)inflateEnd(&z_strm);
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed for deflate uncompression")
+ }
+
+ /* Update pointers to buffer for next set of uncompressed data */
+ z_strm.next_out = (unsigned char*)outbuf + z_strm.total_out;
+ z_strm.avail_out = (uInt)(nalloc - z_strm.total_out);
+ }
+ } /* end else */
+ } while(status==Z_OK);
/* Free the input buffer */
H5MM_xfree(*buf);
@@ -142,7 +143,7 @@ H5Z_filter_deflate (unsigned flags, size_t cd_nelmts,
ret_value = z_strm.total_out;
/* Finish uncompressing the stream */
- inflateEnd(&z_strm);
+ (void)inflateEnd(&z_strm);
}
else {
/*
@@ -157,23 +158,22 @@ H5Z_filter_deflate (unsigned flags, size_t cd_nelmts,
int aggression; /* Compression aggression setting */
/* Set the compression aggression level */
- aggression = cd_values[0];
+ H5_ASSIGN_OVERFLOW(aggression,cd_values[0],unsigned,int);
/* Allocate output (compressed) buffer */
if (NULL==(z_dst=outbuf=H5MM_malloc(z_dst_nbytes)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "unable to allocate deflate destination buffer");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "unable to allocate deflate destination buffer")
/* Perform compression from the source to the destination buffer */
status = compress2 (z_dst, &z_dst_nbytes, z_src, z_src_nbytes, aggression);
/* Check for various zlib errors */
- if (Z_BUF_ERROR==status) {
- HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, 0, "overflow");
- } else if (Z_MEM_ERROR==status) {
- HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, 0, "deflate memory error");
- } else if (Z_OK!=status) {
- HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, 0, "other deflate error");
- }
+ if (Z_BUF_ERROR==status)
+ HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, 0, "overflow")
+ else if (Z_MEM_ERROR==status)
+ HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, 0, "deflate memory error")
+ else if (Z_OK!=status)
+ HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, 0, "other deflate error")
/* Successfully uncompressed the buffer */
else {
/* Free the input buffer */
@@ -190,7 +190,7 @@ H5Z_filter_deflate (unsigned flags, size_t cd_nelmts,
done:
if(outbuf)
H5MM_xfree(outbuf);
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
}
#endif /* H5_HAVE_FILTER_DEFLATE */