diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/dynlib1.c | 25 | ||||
-rw-r--r-- | test/dynlib2.c | 25 | ||||
-rw-r--r-- | test/dynlib3.c | 18 | ||||
-rw-r--r-- | test/plugin.c | 33 |
4 files changed, 49 insertions, 52 deletions
diff --git a/test/dynlib1.c b/test/dynlib1.c index de14f6f..1ccc33a 100644 --- a/test/dynlib1.c +++ b/test/dynlib1.c @@ -20,7 +20,7 @@ #include <stdlib.h> #include <stdio.h> -#include <hdf5.h> +#include "H5PLextern.h" #define H5Z_FILTER_DYNLIB1 257 @@ -38,8 +38,8 @@ const H5Z_class2_t H5Z_DYNLIB1[1] = {{ (H5Z_func_t)H5Z_filter_dynlib1, /* The actual filter function */ }}; -H5PL_type_t H5PL_get_plugin_type(void) {return H5PL_TYPE_FILTER;} -H5Z_class2_t* H5PL_get_plugin_info(void) {return H5Z_DYNLIB1;} +H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;} +const void *H5PLget_plugin_info(void) {return H5Z_DYNLIB1;} /*------------------------------------------------------------------------- * Function: H5Z_filter_dynlib1 @@ -63,34 +63,35 @@ H5Z_filter_dynlib1(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf) { - int *int_ptr=(int *)*buf; /* Pointer to the data values */ - size_t buf_left=*buf_size; /* Amount of data buffer left to process */ - int add_on = 0; + int *int_ptr = (int *)*buf; /* Pointer to the data values */ + size_t buf_left = *buf_size; /* Amount of data buffer left to process */ + int add_on = 0; /* Check for the correct number of parameters */ - if(cd_nelmts==0) + if(cd_nelmts == 0) return(0); /* Check that permanent parameters are set correctly */ - if(cd_values[0]<0 || cd_values[0]>9) + if(cd_values[0] > 9) return(0); - add_on = cd_values[0]; + add_on = (int)cd_values[0]; if(flags & H5Z_FLAG_REVERSE) { /*read*/ /* Substract the "add on" value to all the data values */ - while(buf_left>0) { + while(buf_left > 0) { *int_ptr++ -= add_on; buf_left -= sizeof(int); } /* end while */ } /* end if */ else { /*write*/ /* Add the "add on" value to all the data values */ - while(buf_left>0) { + while(buf_left > 0) { *int_ptr++ += add_on; buf_left -= sizeof(int); } /* end while */ } /* end else */ return nbytes; -} +} /* end H5Z_filter_dynlib1() */ + diff --git a/test/dynlib2.c b/test/dynlib2.c index 648f7e0..a853ed0 100644 --- a/test/dynlib2.c +++ b/test/dynlib2.c @@ -20,7 +20,7 @@ #include <stdlib.h> #include <stdio.h> -#include <hdf5.h> +#include "H5PLextern.h" #define H5Z_FILTER_DYNLIB2 258 #define MULTIPLIER 3 @@ -39,8 +39,8 @@ const H5Z_class2_t H5Z_DYNLIB2[1] = {{ (H5Z_func_t)H5Z_filter_dynlib2, /* The actual filter function */ }}; -H5PL_type_t H5PL_get_plugin_type(void) {return H5PL_TYPE_FILTER;} -H5Z_class2_t* H5PL_get_plugin_info(void) {return H5Z_DYNLIB2;} +H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;} +const void *H5PLget_plugin_info(void) {return H5Z_DYNLIB2;} /*------------------------------------------------------------------------- * Function: H5Z_filter_dynlib2 @@ -64,29 +64,28 @@ H5Z_filter_dynlib2(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf) { - int *int_ptr=(int *)*buf; /* Pointer to the data values */ - size_t buf_left=*buf_size; /* Amount of data buffer left to process */ + int *int_ptr = (int *)*buf; /* Pointer to the data values */ + size_t buf_left = *buf_size; /* Amount of data buffer left to process */ /* Check for the correct number of parameters */ - if(cd_nelmts>0) + if(cd_nelmts > 0) return(0); if(flags & H5Z_FLAG_REVERSE) { /*read*/ /* Divide the original value with MULTIPLIER */ - while(buf_left>0) { - *int_ptr /= MULTIPLIER; - *int_ptr++; + while(buf_left > 0) { + *int_ptr++ /= MULTIPLIER; buf_left -= sizeof(int); } /* end while */ } /* end if */ else { /*write*/ /* Multiply the original value with MULTIPLIER */ - while(buf_left>0) { - *int_ptr *= MULTIPLIER; - *int_ptr++; + while(buf_left > 0) { + *int_ptr++ *= MULTIPLIER; buf_left -= sizeof(int); } /* end while */ } /* end else */ return nbytes; -} +} /* end H5Z_filter_dynlib2() */ + diff --git a/test/dynlib3.c b/test/dynlib3.c index 276a5b7..9560b86 100644 --- a/test/dynlib3.c +++ b/test/dynlib3.c @@ -21,7 +21,7 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> -#include <hdf5.h> +#include "H5PLextern.h" #define H5Z_FILTER_DYNLIB3 259 #define SUFFIX_LEN 8 @@ -41,8 +41,8 @@ const H5Z_class2_t H5Z_DYNLIB3[1] = {{ (H5Z_func_t)H5Z_filter_dynlib3, /* The actual filter function */ }}; -H5PL_type_t H5PL_get_plugin_type(void) {return H5PL_TYPE_FILTER;} -H5Z_class2_t* H5PL_get_plugin_info(void) {return H5Z_DYNLIB3;} +H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;} +const void *H5PLget_plugin_info(void) {return H5Z_DYNLIB3;} /*------------------------------------------------------------------------- * Function: H5Z_filter_dynlib3 @@ -68,23 +68,24 @@ H5Z_filter_dynlib3(unsigned int flags, size_t cd_nelmts, size_t ret_value; /* Return value */ /* Check for the correct number of parameters */ - if(cd_nelmts>0) + if(cd_nelmts > 0) return(0); if(flags & H5Z_FLAG_REVERSE) { /*read*/ ret_value = *buf_size = nbytes - SUFFIX_LEN; - } else { /*write*/ + } /* end if */ + else { /*write*/ void *outbuf = NULL; /* Pointer to new buffer */ unsigned char *dst; /* Temporary pointer to destination buffer */ - dst=outbuf=malloc(nbytes+SUFFIX_LEN); + dst = (unsigned char *)(outbuf = malloc(nbytes + SUFFIX_LEN)); /* Copy raw data */ memcpy((void*)dst, (void*)(*buf), nbytes); /* Append suffix to raw data for storage */ dst += nbytes; - memcpy((void*)dst, (void*)GROUP_SUFFIX, SUFFIX_LEN); + memcpy(dst, (void*)GROUP_SUFFIX, SUFFIX_LEN); /* Free input buffer */ free(*buf); @@ -97,4 +98,5 @@ H5Z_filter_dynlib3(unsigned int flags, size_t cd_nelmts, } /* end else */ return ret_value; -} +} /* H5Z_filter_dynlib3() */ + diff --git a/test/plugin.c b/test/plugin.c index b37cfa3..86bc952 100644 --- a/test/plugin.c +++ b/test/plugin.c @@ -34,9 +34,6 @@ #define H5Z_FILTER_DYNLIB2 258 #define H5Z_FILTER_DYNLIB3 259 -/* Bzip2 filter */ -#define H5Z_FILTER_BZIP2 307 - const char *FILENAME[] = { "plugin", NULL @@ -45,7 +42,6 @@ const char *FILENAME[] = { /* Dataset names for testing filters */ #define DSET_DEFLATE_NAME "deflate" -#define DSET_BZIP2_NAME "bzip2" #define DSET_DYNLIB1_NAME "dynlib1" #define DSET_DYNLIB2_NAME "dynlib2" @@ -156,7 +152,8 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl) */ TESTING(" filters (write)"); - for(i=n=0; i<size[0]; i++) { + n = 0; + for(i=0; i<size[0]; i++) { for(j=0; j<size[1]; j++) { points[i][j] = (int)(n++); } @@ -309,8 +306,6 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl) points_dynlib1[i][j] = points[i][j]; } else if(!HDstrcmp(name, DSET_DYNLIB2_NAME)) { points_dynlib2[i][j] = points[i][j]; - } else if(!HDstrcmp(name, DSET_BZIP2_NAME)) { - points_bzip2[i][j] = points[i][j]; } } } @@ -344,7 +339,7 @@ error: *------------------------------------------------------------------------- */ static herr_t -test_filters_for_datasets(hid_t file, hid_t fapl) +test_filters_for_datasets(hid_t file) { hid_t dc; /* Dataset creation property list ID */ const hsize_t chunk_size[2] = {FILTER_CHUNK_DIM1, FILTER_CHUNK_DIM2}; /* Chunk dimensions */ @@ -474,7 +469,7 @@ error: *------------------------------------------------------------------------- */ static herr_t -test_read_with_filters(hid_t file, hid_t fapl) +test_read_with_filters(hid_t file) { hid_t dset; /* Dataset ID */ @@ -489,7 +484,7 @@ test_read_with_filters(hid_t file, hid_t fapl) if((dset = H5Dopen2(file,DSET_DEFLATE_NAME,H5P_DEFAULT)) < 0) TEST_ERROR - if(test_read_data(dset, points_deflate) < 0) TEST_ERROR + if(test_read_data(dset, (int *)points_deflate) < 0) TEST_ERROR if(H5Dclose(dset) < 0) TEST_ERROR @@ -508,7 +503,7 @@ test_read_with_filters(hid_t file, hid_t fapl) if((dset = H5Dopen2(file,DSET_DYNLIB1_NAME,H5P_DEFAULT)) < 0) TEST_ERROR - if(test_read_data(dset, points_dynlib1) < 0) TEST_ERROR + if(test_read_data(dset, (int *)points_dynlib1) < 0) TEST_ERROR if(H5Dclose(dset) < 0) TEST_ERROR @@ -520,7 +515,7 @@ test_read_with_filters(hid_t file, hid_t fapl) if((dset = H5Dopen2(file,DSET_DYNLIB2_NAME,H5P_DEFAULT)) < 0) TEST_ERROR - if(test_read_data(dset, points_dynlib2) < 0) TEST_ERROR + if(test_read_data(dset, (int *)points_dynlib2) < 0) TEST_ERROR if(H5Dclose(dset) < 0) TEST_ERROR @@ -544,7 +539,7 @@ error: *------------------------------------------------------------------------- */ static herr_t -test_filters_for_groups(hid_t file, hid_t fapl) +test_filters_for_groups(hid_t file) { hid_t gcpl, gid, group; int i; @@ -595,9 +590,9 @@ error: *------------------------------------------------------------------------- */ static herr_t -test_groups_with_filters(hid_t file, hid_t fapl) +test_groups_with_filters(hid_t file) { - hid_t gcpl, gid, group; + hid_t gid, group; int i; char gname[256]; @@ -689,10 +684,10 @@ main(void) TEST_ERROR /* Test dynamically loaded filters for chunked dataset */ - nerrors += (test_filters_for_datasets(file, my_fapl) < 0 ? 1 : 0); + nerrors += (test_filters_for_datasets(file) < 0 ? 1 : 0); /* Test dynamically loaded filters for groups */ - nerrors += (test_filters_for_groups(file, my_fapl) < 0 ? 1 : 0); + nerrors += (test_filters_for_groups(file) < 0 ? 1 : 0); if(H5Fclose(file) < 0) TEST_ERROR @@ -713,10 +708,10 @@ main(void) TEST_ERROR /* Read the data with filters */ - nerrors += (test_read_with_filters(file, fapl) < 0 ? 1 : 0); + nerrors += (test_read_with_filters(file) < 0 ? 1 : 0); /* Open the groups with filters */ - nerrors += (test_groups_with_filters(file, fapl) < 0 ? 1 : 0); + nerrors += (test_groups_with_filters(file) < 0 ? 1 : 0); if(H5Fclose(file) < 0) TEST_ERROR |