diff options
author | Scot Breitenfeld <brtnfld@hdfgroup.org> | 2015-03-27 15:16:25 (GMT) |
---|---|---|
committer | Scot Breitenfeld <brtnfld@hdfgroup.org> | 2015-03-27 15:16:25 (GMT) |
commit | de11710fdad2481f158825581116dde77fc85134 (patch) | |
tree | 20778ebdf3185b6f36d46f3d454f92b01d0aecdd | |
parent | 6abce0d37448084b4105e64c2aa059679817e85b (diff) | |
download | hdf5-de11710fdad2481f158825581116dde77fc85134.zip hdf5-de11710fdad2481f158825581116dde77fc85134.tar.gz hdf5-de11710fdad2481f158825581116dde77fc85134.tar.bz2 |
[svn-r26615] merged r26575 from the trunk into the branch.
Tested: h5committest
-rw-r--r-- | hl/src/H5DS.c | 64 | ||||
-rw-r--r-- | hl/tools/gif2h5/decompress.c | 2 | ||||
-rw-r--r-- | hl/tools/gif2h5/gif2mem.c | 10 | ||||
-rw-r--r-- | hl/tools/gif2h5/h52gifgentst.c | 8 | ||||
-rw-r--r-- | hl/tools/gif2h5/hdf2gif.c | 8 | ||||
-rw-r--r-- | hl/tools/gif2h5/hdfgifwr.c | 8 |
6 files changed, 52 insertions, 48 deletions
diff --git a/hl/src/H5DS.c b/hl/src/H5DS.c index eb5069a..0df4270 100644 --- a/hl/src/H5DS.c +++ b/hl/src/H5DS.c @@ -1430,10 +1430,12 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) hid_t aid = -1; /* attribute ID */ int rank; /* rank of dataset */ hsize_t dims[1]; /* dimensions of dataset */ - const char **buf = NULL; /* buffer to store in the attribute */ H5I_type_t it; /* ID type */ unsigned int i; - + union { /* union is needed to eliminate compiler warnings about */ + char ** buf; /* discarding the 'const' qualifier in the free */ + char const ** const_buf; /* buf calls */ + } u; /*------------------------------------------------------------------------- * parameter checking *------------------------------------------------------------------------- @@ -1496,19 +1498,19 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) goto out; /* allocate and initialize */ - buf = (const char **) HDmalloc((size_t) rank * sizeof(char *)); + u.const_buf = (char const **) HDmalloc((size_t) rank * sizeof(char *)); - if (buf == NULL) + if (u.const_buf == NULL) goto out; for (i = 0; i < (unsigned int) rank; i++) - buf[i] = NULL; + u.const_buf[i] = NULL; /* store the label information in the required index */ - buf[idx] = label; + u.const_buf[idx] = label; /* write the attribute with the label */ - if (H5Awrite(aid, tid, buf) < 0) + if (H5Awrite(aid, tid, u.const_buf) < 0) goto out; /* close */ @@ -1518,10 +1520,10 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) goto out; if (H5Aclose(aid) < 0) goto out; - if (buf) + if (u.const_buf) { - HDfree(buf); - buf = NULL; + HDfree(u.const_buf); + u.const_buf = NULL; } } @@ -1532,6 +1534,7 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) else { + if ((aid = H5Aopen(did, DIMENSION_LABELS, H5P_DEFAULT)) < 0) goto out; @@ -1539,34 +1542,34 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) goto out; /* allocate and initialize */ - buf = (const char **) HDmalloc((size_t) rank * sizeof(char *)); - - if (buf == NULL) + u.buf = (char **) HDmalloc((size_t) rank * sizeof(char *)); + + if (u.buf == NULL) goto out; /* read */ - if (H5Aread(aid, tid, (void *) buf) < 0) + if (H5Aread(aid, tid, (void *)u.buf) < 0) goto out; /* free the ptr that will be replaced by label */ - if (buf[idx]) - HDfree((void *)buf[idx]); + if (u.buf[idx]) + HDfree(u.buf[idx]); /* store the label information in the required index */ - buf[idx] = label; + u.const_buf[idx] = label; /* write the attribute with the new references */ - if (H5Awrite(aid, tid, buf) < 0) + if (H5Awrite(aid, tid, u.buf) < 0) goto out; /* label was brought in, so don't free */ - buf[idx] = NULL; + u.buf[idx] = NULL; /* free all the ptr's from the H5Aread() */ for (i = 0; i < (unsigned int) rank; i++) { - if (buf[i]) - HDfree((void *)buf[i]); + if (u.buf[i]) + HDfree(u.buf[i]); } /* close */ @@ -1574,28 +1577,29 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) goto out; if (H5Aclose(aid) < 0) goto out; - if (buf) + if (u.buf) { - HDfree(buf); - buf = NULL; + HDfree(u.buf); + u.buf = NULL; } } return SUCCEED; /* error zone */ + out: - if (buf) + if (u.buf) { - if (buf[idx]) /* check if we errored during H5Awrite */ - buf[idx] = NULL; /* don't free label */ + if (u.buf[idx]) /* check if we errored during H5Awrite */ + u.buf[idx] = NULL; /* don't free label */ /* free all the ptr's from the H5Aread() */ for (i = 0; i < (unsigned int) rank; i++) { - if (buf[i]) - HDfree((void *)buf[i]); + if (u.buf[i]) + HDfree(u.buf[i]); } - HDfree(buf); + HDfree(u.buf); } H5E_BEGIN_TRY { diff --git a/hl/tools/gif2h5/decompress.c b/hl/tools/gif2h5/decompress.c index d4e4cdc..ef2d78a 100644 --- a/hl/tools/gif2h5/decompress.c +++ b/hl/tools/gif2h5/decompress.c @@ -90,7 +90,7 @@ ReadCode(void) RawCode += (0x10000 * Raster[ByteOffset + 2]); RawCode >>= (BitOffset % 8); - BitOffset += CodeSize; + BitOffset += (int)CodeSize; return (RawCode & ReadMask); } diff --git a/hl/tools/gif2h5/gif2mem.c b/hl/tools/gif2h5/gif2mem.c index ac4b0ec..d816aa1 100644 --- a/hl/tools/gif2h5/gif2mem.c +++ b/hl/tools/gif2h5/gif2mem.c @@ -155,7 +155,7 @@ Gif2Mem(BYTE *MemGif) if (ImageCount > ImageArray) { aTemp = ImageArray; - ImageArray = (ImageArray << 1) + 1; + ImageArray = (BYTE)((ImageArray << 1) + 1); if (!(gifImageDesc = (GIFIMAGEDESC **)realloc(gifImageDesc, sizeof(GIFIMAGEDESC *) * ImageArray))) { printf("Out of memory!"); @@ -222,7 +222,7 @@ Gif2Mem(BYTE *MemGif) PlainTextCount++; if (PlainTextCount > PlainTextArray) - PlainTextArray = (PlainTextArray << 1) + 1; + PlainTextArray = (BYTE)((PlainTextArray << 1) + 1); if (!(gifPlainText = (GIFPLAINTEXT **)realloc(gifPlainText , sizeof(GIFPLAINTEXT *) * PlainTextArray))) { printf("Out of memory!"); @@ -244,7 +244,7 @@ Gif2Mem(BYTE *MemGif) CommentCount++; if (CommentCount > CommentArray) - CommentArray = (CommentArray << 1) + 1; + CommentArray = (BYTE)((CommentArray << 1) + 1); if (!(gifComment = (GIFCOMMENT **)realloc(gifComment , sizeof(GIFCOMMENT *) * CommentArray))) { printf("Out of memory!"); @@ -271,7 +271,7 @@ Gif2Mem(BYTE *MemGif) if (ImageCount > ImageArray) { aTemp = ImageArray; - ImageArray = (ImageArray << 1) + 1; + ImageArray = (BYTE)((ImageArray << 1) + 1); if (!(gifGraphicControl = (GIFGRAPHICCONTROL **)realloc(gifGraphicControl , sizeof(GIFGRAPHICCONTROL *) * ImageArray))) { printf("Out of memory!"); @@ -309,7 +309,7 @@ Gif2Mem(BYTE *MemGif) ApplicationCount++; if (ApplicationCount > ApplicationArray) - ApplicationArray = (ApplicationArray << 1) + 1; + ApplicationArray = (BYTE)((ApplicationArray << 1) + 1); if (!(gifApplication = (GIFAPPLICATION **)realloc(gifApplication , sizeof(GIFAPPLICATION *) * ApplicationArray))) { printf("Out of memory!"); diff --git a/hl/tools/gif2h5/h52gifgentst.c b/hl/tools/gif2h5/h52gifgentst.c index ef38c3b..3433d0a 100644 --- a/hl/tools/gif2h5/h52gifgentst.c +++ b/hl/tools/gif2h5/h52gifgentst.c @@ -64,7 +64,7 @@ int main(void) space = WIDTH*HEIGHT / PAL_ENTRIES; for (i=0, j=0, n=0; i < WIDTH*HEIGHT; i++, j++ ) { - buf[i] = n; + buf[i] = (unsigned char)n; if ( j > space ) { n++; @@ -83,9 +83,9 @@ int main(void) */ for ( i=0, n=0; i<PAL_ENTRIES*3; i+=3, n++) { - pal[i] =n; /* red */ - pal[i+1]=0; /* green */ - pal[i+2]=255-n; /* blue */ + pal[i] = (unsigned char)n; /* red */ + pal[i+1] = (unsigned char)0; /* green */ + pal[i+2] = (unsigned char)(255-n); /* blue */ } /* make a palette */ diff --git a/hl/tools/gif2h5/hdf2gif.c b/hl/tools/gif2h5/hdf2gif.c index 090d657..fe79975 100644 --- a/hl/tools/gif2h5/hdf2gif.c +++ b/hl/tools/gif2h5/hdf2gif.c @@ -194,9 +194,9 @@ int main(int argc , char **argv) numcols = 256; for (i = 0 ; i < numcols ; i++) { - Red[i] = 255 - i; - Green[i] = 255 - i; - Blue[i] = 255 - i; + Red[i] = (BYTE)(255 - i); + Green[i] = (BYTE)(255 - i); + Blue[i] = (BYTE)(255 - i); } } else @@ -229,7 +229,7 @@ int main(int argc , char **argv) if (j==i) { /* wasn't found */ - pc2nc[i] = nc; + pc2nc[i] = (BYTE)nc; r1[nc] = Red[i]; g1[nc] = Green[i]; b1[nc] = Blue[i]; diff --git a/hl/tools/gif2h5/hdfgifwr.c b/hl/tools/gif2h5/hdfgifwr.c index d828226..4c52f4c 100644 --- a/hl/tools/gif2h5/hdfgifwr.c +++ b/hl/tools/gif2h5/hdfgifwr.c @@ -270,7 +270,7 @@ nomatch: ent = c; if (free_ent < maxmaxcode) { - CodeTabOf (i) = free_ent++; /* code -> hashtable */ + CodeTabOf (i) = (unsigned short)free_ent++; /* code -> hashtable */ HashTabOf (i) = fcode; } else { cl_block(); @@ -313,9 +313,9 @@ output(int code) cur_accum &= masks[cur_bits]; if (cur_bits > 0) - cur_accum |= ((long)code << cur_bits); + cur_accum |= (unsigned long)((long)code << cur_bits); else - cur_accum = code; + cur_accum = (unsigned long)code; cur_bits += n_bits; @@ -437,7 +437,7 @@ static char accum[ 256 ]; static void char_out(int c) { - accum[ a_count++ ] = c; + accum[ a_count++ ] = (char)c; if (a_count >= 254) flush_char(); |