diff options
author | Dana Robinson <derobins@hdfgroup.org> | 2020-07-31 18:58:46 (GMT) |
---|---|---|
committer | Dana Robinson <derobins@hdfgroup.org> | 2020-07-31 18:58:46 (GMT) |
commit | bfe04875838d8c3baea58c3fbfb16d9ee88d3beb (patch) | |
tree | f21d4753e48dad48367633f5a55a23e72cd9dbf6 /test/vfd.c | |
parent | f977c4dfd0e5eb6f6e8527bdc9e48edebe500d78 (diff) | |
download | hdf5-bfe04875838d8c3baea58c3fbfb16d9ee88d3beb.zip hdf5-bfe04875838d8c3baea58c3fbfb16d9ee88d3beb.tar.gz hdf5-bfe04875838d8c3baea58c3fbfb16d9ee88d3beb.tar.bz2 |
Normalization and warning fixes from develop
Diffstat (limited to 'test/vfd.c')
-rw-r--r-- | test/vfd.c | 125 |
1 files changed, 84 insertions, 41 deletions
@@ -562,6 +562,7 @@ test_direct(void) size_t mbound; size_t fbsize; size_t cbsize; + void *proto_points = NULL, *proto_check = NULL; int *points = NULL, *check = NULL, *p1 = NULL, *p2 = NULL; int wdata2[DSET2_DIM] = {11,12,13,14}; int rdata2[DSET2_DIM]; @@ -633,10 +634,12 @@ test_direct(void) /* Allocate aligned memory for data set 1. For data set 1, everything is aligned including * memory address, size of data, and file address. */ - if(0 != HDposix_memalign(&points, (size_t)FBSIZE, (size_t)(DSET1_DIM1 * DSET1_DIM2 * sizeof(int)))) + if(0 != HDposix_memalign(&proto_points, (size_t)FBSIZE, (size_t)(DSET1_DIM1 * DSET1_DIM2 * sizeof(int)))) TEST_ERROR; - if(0 != HDposix_memalign(&check, (size_t)FBSIZE, (size_t)(DSET1_DIM1 * DSET1_DIM2 * sizeof(int)))) + points = proto_points; + if(0 != HDposix_memalign(&proto_check, (size_t)FBSIZE, (size_t)(DSET1_DIM1 * DSET1_DIM2 * sizeof(int)))) TEST_ERROR; + check = proto_check; /* Initialize the dset1 */ p1 = points; @@ -746,10 +749,10 @@ error: H5Fclose(file); } H5E_END_TRY; - if(points) - HDfree(points); - if(check) - HDfree(check); + if(proto_points) + HDfree(proto_points); + if(proto_check) + HDfree(proto_check); return -1; #endif /*H5_HAVE_DIRECT*/ @@ -776,8 +779,7 @@ error: * 'first_name' in the code below, but early (4.4.7, at least) gcc only * allows diagnostic pragmas to be toggled outside of functions. */ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wformat-nonliteral" +H5_GCC_DIAG_OFF(format-nonliteral) static herr_t test_family_opens(char *fname, hid_t fa_pl) { @@ -834,7 +836,7 @@ test_family_opens(char *fname, hid_t fa_pl) error: return -1; } /* end test_family_opens() */ -#pragma GCC diagnostic pop +H5_GCC_DIAG_ON(format-nonliteral) /*------------------------------------------------------------------------- @@ -842,8 +844,7 @@ error: * * Purpose: Tests the file handle interface for FAMILY driver * - * Return: Success: 0 - * Failure: -1 + * Return: SUCCEED/FAIL * * Programmer: Raymond Lu * Tuesday, Sept 24, 2002 @@ -858,15 +859,24 @@ test_family(void) hid_t driver_id = -1; /* ID for this VFD */ unsigned long driver_flags = 0; /* VFD feature flags */ char filename[1024]; - char dname[]="dataset"; + char dname[] = "dataset"; unsigned int i, j; int *fhandle=NULL, *fhandle2=NULL; - int buf[FAMILY_NUMBER][FAMILY_SIZE]; + int **buf = NULL; + int *buf_data = NULL; hsize_t dims[2]={FAMILY_NUMBER, FAMILY_SIZE}; hsize_t file_size; TESTING("FAMILY file driver"); + /* Set up data array */ + if(NULL == (buf_data = (int *)HDcalloc(FAMILY_NUMBER * FAMILY_SIZE, sizeof(int)))) + TEST_ERROR; + if(NULL == (buf = (int **)HDcalloc(FAMILY_NUMBER, sizeof(buf_data)))) + TEST_ERROR; + for (i = 0; i < FAMILY_NUMBER; i++) + buf[i] = buf_data + (i * FAMILY_SIZE); + /* Set property list and file name for FAMILY driver */ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR; @@ -890,7 +900,7 @@ test_family(void) | H5FD_FEAT_AGGREGATE_SMALLDATA)) TEST_ERROR - if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR; if(H5Fclose(file) < 0) @@ -905,7 +915,7 @@ test_family(void) if(H5Pset_fapl_family(fapl, (hsize_t)H5F_FAMILY_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; - if((file=H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR; /* Check file size API */ @@ -917,7 +927,7 @@ test_family(void) TEST_ERROR; /* Create and write dataset */ - if((space=H5Screate_simple(2, dims, NULL)) < 0) + if((space = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR; /* Retrieve the access property list... */ @@ -932,14 +942,14 @@ test_family(void) if (H5Pclose(access_fapl) < 0) TEST_ERROR; - if((dset=H5Dcreate2(file, dname, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if((dset = H5Dcreate2(file, dname, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; for(i = 0; i < FAMILY_NUMBER; i++) for(j = 0; j < FAMILY_SIZE; j++) buf[i][j] = (int)((i * 10000) + j); - if(H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if(H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_data) < 0) TEST_ERROR; /* check file handle API */ @@ -1004,8 +1014,11 @@ test_family(void) if(H5Pclose(fapl) < 0) TEST_ERROR; + HDfree(buf); + HDfree(buf_data); + PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -1015,8 +1028,12 @@ error: H5Pclose(fapl2); H5Fclose(file); } H5E_END_TRY; - return -1; -} + + HDfree(buf); + HDfree(buf_data); + + return FAIL; +} /* end test_family() */ /*------------------------------------------------------------------------- @@ -1043,8 +1060,7 @@ error: * 'newname_individual', etc. in the code below, but early (4.4.7, at least) gcc only * allows diagnostic pragmas to be toggled outside of functions. */ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wformat-nonliteral" +H5_GCC_DIAG_OFF(format-nonliteral) static herr_t test_family_compat(void) { @@ -1128,7 +1144,7 @@ error: return -1; } /* end test_family_compat() */ -#pragma GCC diagnostic pop +H5_GCC_DIAG_ON(format-nonliteral) /*------------------------------------------------------------------------- @@ -1150,8 +1166,7 @@ error: * 'sf_name' in the code below, but early (4.4.7, at least) gcc only * allows diagnostic pragmas to be toggled outside of functions. */ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wformat-nonliteral" +H5_GCC_DIAG_OFF(format-nonliteral) static herr_t test_multi_opens(char *fname) { @@ -1169,7 +1184,7 @@ test_multi_opens(char *fname) return(fid >= 0 ? FAIL : SUCCEED); } /* end test_multi_opens() */ -#pragma GCC diagnostic pop +H5_GCC_DIAG_ON(format-nonliteral) /*------------------------------------------------------------------------- @@ -1205,10 +1220,19 @@ test_multi(void) char dname[]="dataset"; char meta[] = "this is some metadata on this file"; int i, j; - int buf[MULTI_SIZE][MULTI_SIZE]; + int **buf = NULL; + int *buf_data = NULL; TESTING("MULTI file driver"); + /* Set up data array */ + if(NULL == (buf_data = (int *)HDcalloc(MULTI_SIZE * MULTI_SIZE, sizeof(int)))) + TEST_ERROR; + if(NULL == (buf = (int **)HDcalloc(MULTI_SIZE, sizeof(buf_data)))) + TEST_ERROR; + for (i = 0; i < MULTI_SIZE; i++) + buf[i] = buf_data + (i * MULTI_SIZE); + /* Set file access property list for MULTI driver */ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR; @@ -1311,7 +1335,7 @@ test_multi(void) for(i=0; i<MULTI_SIZE; i++) for(j=0; j<MULTI_SIZE; j++) buf[i][j] = i*10000+j; - if(H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if(H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_data) < 0) TEST_ERROR; if((fapl2=H5Pcreate(H5P_FILE_ACCESS)) < 0) @@ -1389,6 +1413,9 @@ test_multi(void) if(H5Pclose(fapl) < 0) TEST_ERROR; + HDfree(buf); + HDfree(buf_data); + PASSED(); return SUCCEED; @@ -1402,6 +1429,10 @@ error: H5Fclose(file); H5Aclose(attr); } H5E_END_TRY; + + HDfree(buf); + HDfree(buf_data); + return FAIL; } /* end test_multi() */ @@ -1440,10 +1471,19 @@ test_multi_compat(void) char sv[H5FD_MEM_NTYPES][32]; hsize_t dims[2]={MULTI_SIZE, MULTI_SIZE}; int i, j; - int buf[MULTI_SIZE][MULTI_SIZE]; + int **buf = NULL; + int *buf_data = NULL; TESTING("MULTI file driver backward compatibility"); + /* Set up data array */ + if(NULL == (buf_data = (int *)HDcalloc(MULTI_SIZE * MULTI_SIZE, sizeof(int)))) + TEST_ERROR; + if(NULL == (buf = (int **)HDcalloc(MULTI_SIZE, sizeof(buf_data)))) + TEST_ERROR; + for (i = 0; i < MULTI_SIZE; i++) + buf[i] = buf_data + (i * MULTI_SIZE); + /* Set file access property list for MULTI driver */ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR; @@ -1527,7 +1567,7 @@ test_multi_compat(void) for(i=0; i<MULTI_SIZE; i++) for(j=0; j<MULTI_SIZE; j++) buf[i][j] = i*10000+j; - if(H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if(H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_data) < 0) TEST_ERROR; if(H5Dclose(dset) < 0) @@ -1565,9 +1605,12 @@ test_multi_compat(void) if(H5Pclose(fapl) < 0) TEST_ERROR; + HDfree(buf); + HDfree(buf_data); + PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -1576,8 +1619,12 @@ error: H5Pclose(fapl); H5Fclose(file); } H5E_END_TRY; - return -1; -} + + HDfree(buf); + HDfree(buf_data); + + return FAIL; +} /* end test_multi_compat() */ /*------------------------------------------------------------------------- @@ -2020,11 +2067,7 @@ error: * * Purpose: Tests the basic features of Virtual File Drivers * - * Return: Success: 0 - * Failure: 1 - * - * Programmer: Raymond Lu - * Tuesday, Sept 24, 2002 + * Return: EXIT_SUCCESS/EXIT_FAILURE * *------------------------------------------------------------------------- */ @@ -2052,11 +2095,11 @@ main(void) if(nerrors) { HDprintf("***** %d Virtual File Driver TEST%s FAILED! *****\n", nerrors, nerrors > 1 ? "S" : ""); - return 1; + return EXIT_FAILURE; } /* end if */ HDprintf("All Virtual File Driver tests passed.\n"); - return 0; + return EXIT_SUCCESS; } /* end main() */ |