diff options
author | kmu <kmu@hdfgroup.org> | 2019-11-25 18:48:51 (GMT) |
---|---|---|
committer | kmu <kmu@hdfgroup.org> | 2019-11-25 18:48:51 (GMT) |
commit | d242a900f420b040e364f6c0976c01593e955db3 (patch) | |
tree | 7b6849d8aff9ab9c9fe4b8f6ac40113e69454de3 /tools | |
parent | 3613ec7296a782c86ea5f0706a5a0cb51602abc9 (diff) | |
download | hdf5-d242a900f420b040e364f6c0976c01593e955db3.zip hdf5-d242a900f420b040e364f6c0976c01593e955db3.tar.gz hdf5-d242a900f420b040e364f6c0976c01593e955db3.tar.bz2 |
fix issues from previous PR comments
Diffstat (limited to 'tools')
-rw-r--r-- | tools/src/h5import/h5import.c | 12 | ||||
-rw-r--r-- | tools/test/h5diff/dynlib_diff.c | 5 | ||||
-rw-r--r-- | tools/test/h5dump/dynlib_dump.c | 5 | ||||
-rw-r--r-- | tools/test/h5dump/h5dumpgentest.c | 16 | ||||
-rw-r--r-- | tools/test/h5ls/dynlib_ls.c | 3 | ||||
-rw-r--r-- | tools/test/h5repack/h5repackgentest.c | 2 |
6 files changed, 26 insertions, 17 deletions
diff --git a/tools/src/h5import/h5import.c b/tools/src/h5import/h5import.c index 40b812f..2cd826b 100644 --- a/tools/src/h5import/h5import.c +++ b/tools/src/h5import/h5import.c @@ -4707,14 +4707,20 @@ static int process(struct Options *opt) return (0); } -uint16_t swap_uint16( uint16_t val) +uint16_t swap_uint16(uint16_t val) { - return (uint16_t)((val << 8) | (val >> 8)); + uint16_t ret; + + ASSIGN_TO_SMALLER_SIZE(ret, uint16_t, (val << 8) | (val >> 8), int); + return ret; } int16_t swap_int16(int16_t val) { - return (uint16_t)((val << 8) | ((val >> 8) & 0xFF)); + uint16_t ret; + + ASSIGN_TO_SMALLER_SIZE(ret, int16_t, (val << 8) | ((val >> 8) & 0xFF), int); + return ret; } uint32_t swap_uint32(uint32_t val) diff --git a/tools/test/h5diff/dynlib_diff.c b/tools/test/h5diff/dynlib_diff.c index 4f2d435..5989b38 100644 --- a/tools/test/h5diff/dynlib_diff.c +++ b/tools/test/h5diff/dynlib_diff.c @@ -16,6 +16,7 @@ #include <stdlib.h> #include <stdio.h> #include "H5PLextern.h" +#include "H5private.h" #define H5Z_FILTER_DYNLIBUD 300 #define MULTIPLIER 3 @@ -69,7 +70,7 @@ H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, /* Subtract the original value with MULTIPLIER */ while(buf_left > 0) { char temp = *int_ptr; - *int_ptr = (char)(temp - MULTIPLIER); + ASSIGN_TO_SMALLER_SIZE(*int_ptr, char, temp - MULTIPLIER, int); int_ptr++; buf_left -= sizeof(*int_ptr); } /* end while */ @@ -78,7 +79,7 @@ H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, /* Add the original value with MULTIPLIER */ while(buf_left > 0) { char temp = *int_ptr; - *int_ptr = (char)(temp + MULTIPLIER); + ASSIGN_TO_SMALLER_SIZE(*int_ptr, char, temp + MULTIPLIER, int); int_ptr++; buf_left -= sizeof(*int_ptr); } /* end while */ diff --git a/tools/test/h5dump/dynlib_dump.c b/tools/test/h5dump/dynlib_dump.c index 4f2d435..5989b38 100644 --- a/tools/test/h5dump/dynlib_dump.c +++ b/tools/test/h5dump/dynlib_dump.c @@ -16,6 +16,7 @@ #include <stdlib.h> #include <stdio.h> #include "H5PLextern.h" +#include "H5private.h" #define H5Z_FILTER_DYNLIBUD 300 #define MULTIPLIER 3 @@ -69,7 +70,7 @@ H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, /* Subtract the original value with MULTIPLIER */ while(buf_left > 0) { char temp = *int_ptr; - *int_ptr = (char)(temp - MULTIPLIER); + ASSIGN_TO_SMALLER_SIZE(*int_ptr, char, temp - MULTIPLIER, int); int_ptr++; buf_left -= sizeof(*int_ptr); } /* end while */ @@ -78,7 +79,7 @@ H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, /* Add the original value with MULTIPLIER */ while(buf_left > 0) { char temp = *int_ptr; - *int_ptr = (char)(temp + MULTIPLIER); + ASSIGN_TO_SMALLER_SIZE(*int_ptr, char, temp + MULTIPLIER, int); int_ptr++; buf_left -= sizeof(*int_ptr); } /* end while */ diff --git a/tools/test/h5dump/h5dumpgentest.c b/tools/test/h5dump/h5dumpgentest.c index 85fe754..2f8c1a6 100644 --- a/tools/test/h5dump/h5dumpgentest.c +++ b/tools/test/h5dump/h5dumpgentest.c @@ -2565,7 +2565,7 @@ static void gent_bitfields(void) goto error; for(i = 0; i < sizeof buf; i++) - buf[i] = (unsigned char)(0xff ^ i); + ASSIGN_TO_SMALLER_SIZE(buf[i], unsigned char, 0xff ^ i, size_t); if(H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto error; if(H5Sclose(space) < 0) goto error; @@ -2579,7 +2579,7 @@ static void gent_bitfields(void) (dset = H5Dcreate2(grp, "bitfield_2", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; for(i = 0; i < sizeof buf; i++) - buf[i] = (unsigned char)(0xff ^ i); + ASSIGN_TO_SMALLER_SIZE(buf[i], unsigned char, 0xff ^ i, size_t); if(H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto error; if(H5Sclose(space) < 0) goto error; @@ -9814,7 +9814,7 @@ static void gent_bitnopaquefields(void) if ((space = H5Screate_simple(1, &nelmts, NULL)) >= 0) { if ((dset = H5Dcreate2(grp, "bitfield_1", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { for (i = 0; i < nelmts; i++) { - buf[i] = (uint8_t)(0xff ^ i); + ASSIGN_TO_SMALLER_SIZE(buf[i], uint8_t, 0xff ^ i, size_t); } H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); H5Dclose(dset); @@ -9829,7 +9829,7 @@ static void gent_bitnopaquefields(void) if ((space = H5Screate_simple(1, &nelmts, NULL)) >= 0) { if ((dset = H5Dcreate2(grp, "bitfield_2", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { for (i = 0; i < nelmts; i++) { - buf2[i] = (uint16_t)(0xffff ^ (i * 16)); + ASSIGN_TO_SMALLER_SIZE(buf2[i], uint16_t, 0xffff ^ (i * 16), size_t); } H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2); H5Dclose(dset); @@ -9879,7 +9879,7 @@ static void gent_bitnopaquefields(void) if ((space = H5Screate_simple(1, &nelmts, NULL)) >= 0) { if ((dset = H5Dcreate2(grp, "opaque_1", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { for(i = 0; i < nelmts; i++) - buf[i] = (uint8_t)(0xff ^ i); + ASSIGN_TO_SMALLER_SIZE(buf[i], uint8_t, 0xff ^ i, size_t); H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); H5Dclose(dset); } @@ -9895,7 +9895,7 @@ static void gent_bitnopaquefields(void) if ((space = H5Screate_simple(1, &nelmts, NULL)) >= 0) { if ((dset = H5Dcreate2(grp, "opaque_2", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { for(i = 0; i < nelmts; i++) - buf2[i] = (uint16_t)(0xffff ^ (i * 16)); + ASSIGN_TO_SMALLER_SIZE(buf2[i], uint16_t, 0xffff ^ (i * 16), size_t); H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2); H5Dclose(dset); @@ -9918,8 +9918,8 @@ static void gent_bitnopaquefields(void) if ((space = H5Screate_simple(1, &nelmts, NULL)) >= 0) { if ((dset = H5Dcreate2(grp, "compound_1", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { for(i = 0; i < nelmts; i++) { - buf5[i].a = (uint8_t)(0xff ^ i); - buf5[i].b = (uint16_t)(0xffff ^ (i * 16)); + ASSIGN_TO_SMALLER_SIZE(buf5[i].a, uint8_t, 0xff ^ i, size_t); + ASSIGN_TO_SMALLER_SIZE(buf5[i].b, uint16_t, 0xffff ^ (i * 16), size_t); buf5[i].c = (uint32_t)0xffffffff ^ (uint32_t)(i * 32); buf5[i].d = (uint64_t)0xffffffffffffffff ^ (uint64_t)(i * 64); } diff --git a/tools/test/h5ls/dynlib_ls.c b/tools/test/h5ls/dynlib_ls.c index 4f2d435..089b78f 100644 --- a/tools/test/h5ls/dynlib_ls.c +++ b/tools/test/h5ls/dynlib_ls.c @@ -16,6 +16,7 @@ #include <stdlib.h> #include <stdio.h> #include "H5PLextern.h" +#include "H5private.h" #define H5Z_FILTER_DYNLIBUD 300 #define MULTIPLIER 3 @@ -69,7 +70,7 @@ H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, /* Subtract the original value with MULTIPLIER */ while(buf_left > 0) { char temp = *int_ptr; - *int_ptr = (char)(temp - MULTIPLIER); + ASSIGN_TO_SMALLER_SIZE(*int_ptr, char, temp - MULTIPLIER, int); int_ptr++; buf_left -= sizeof(*int_ptr); } /* end while */ diff --git a/tools/test/h5repack/h5repackgentest.c b/tools/test/h5repack/h5repackgentest.c index f476a16..f3cb7d9 100644 --- a/tools/test/h5repack/h5repackgentest.c +++ b/tools/test/h5repack/h5repackgentest.c @@ -266,7 +266,7 @@ generate_uint8be(hbool_t external) { for (i = 0, n = 0; i < dims[0]; i++) { for (j = 0; j < dims[1]; j++) { for (k = 0; k < dims[2]; k++, n++) { - wdata[n] = (uint8_t)(n * ((n & 1) ? (-1) : (1))); + ASSIGN_TO_SMALLER_SIZE(wdata[n], uint8_t, n * ((n & 1) ? (-1) : (1)), int); } } } |